Save the response body to a file

 === Example

   client = Client.new
   client.save 'out.json', 'some/to/resource', param: value
191748
def save(filename, path, params={})
      payload = get! path, nil, params
      File.write filename, payload.response.body
    end
832273
def save(self, path):
        
        with open(path, 'w') as out_file:
            json.dump(self.to_dict(), out_file, indent=4)
1216514
def save_response_to_file(self, response, filename):
        
        try:
            last_response = self.get_last_response()
            with open(filename, 'w') as f:
                f.write(last_response.content)
        except OSError, e:
            return False
        return True
463239
def save_input_meta(self):
        
        options = self.options
        file_path = os.path.join(options.outputdir, 'input.meta.json')
        with open(file_path, 'w') as outfile:
            json.dump(vars(options), outfile)
905530
def save(self):
        
        resp = self._client.put(type(self).api_endpoint, model=self,
            data=self._serialize())

        if 'error' in resp:
            return False
        return True
919120
def save(self, output=''):
        
        self.file = self._get_output_file(output)
        with open(self.file, 'w', encoding='utf-8') as f:
            self.write(f)
933375
def save(self):
        
        if 'save' not in self._supports:
            raise AssertionError('Can not save this object type')

        values = {}
        for key in [key for key in self.keys() if key not in self._save_ignore]:
            if not getattr(self, key) and getattr(self, key) != False:
                continue

            if isinstance(getattr(self, key, None), list):
                value = list()
                for item in getattr(self, key):
                    if isinstance(item, dict):
                        value.append(item)
                    elif hasattr(item, '_save_as'):
                        value.append(item._save_as())
                    elif hasattr(item, '_ref') and getattr(item, '_ref'):
                        value.append(getattr(item, '_ref'))
                    else:
                        LOGGER.warning('Cant assign %r', item)
                values[key] = value
            elif getattr(self, key, None):
                values[key] = getattr(self, key)
        if not self._ref:
            response = self._session.post(self._path, values)
        else:
            values['_ref'] = self._ref
            response = self._session.put(self._path, values)
        LOGGER.debug('Response: %r, %r', response.status_code, response.content)
        if 200 <= response.status_code <= 201:
            self.fetch()
            return True
        else:
            try:
                error = response.json()
                raise exceptions.ProtocolError(error['text'])
            except ValueError:
                raise exceptions.ProtocolError(response.content)
735407
def to_output(self, value):
        """"""
        return json.loads(resolwe_runtime_utils.save_file(self.name, value.path, *value.refs))
85274
def save_file(data_file, data, dry_run=None):
    """"""
    if dry_run:
        return

    with open(data_file, 'w', encoding='utf-8') as f:
        if sys.version_info > (3, 0):
            f.write(json.dumps(data))
        else:
            f.write(json.dumps(data).decode('utf-8'))
1234298
def save(url, destination):
    
    r = requests.get(url, stream=True)

    with open(destination, 'wb') as fd:
        for chunk in r.iter_content(chunk_size=128):
            fd.write(chunk)
1337219
def save!(_options = {})
      return false if respond_to?(:destroyed?) && destroyed?

      options = { request_namespace => attributes }

      if new_record?
        method = :post
        req_path = api_url(options)
      else
        method = :put
        req_path = api_url(options) + "/#{id}"
      end

      response = @client.make_request!(req_path, method, options)

      handle_response(response)
      self
    end
630512
def save_pickle(obj, outfile, protocol=2):
    
    with open(outfile, 'wb') as f:
        pickle.dump(obj, f, protocol=protocol)

    return outfile
400064
def _save_if_needed(request, response_content):
    
    if request.save_response:
        file_path = request.get_file_path()
        create_parent_folder(file_path)
        with open(file_path, 'wb') as file:
            file.write(response_content)
        LOGGER.debug('Saved data from %s to %s', request.url, file_path)
1029465
def save_json(self, frames):
        
        if self.json_save_path is None: return
        path = os.path.join(self.json_save_path, '%s.json' % self.id)
        if not os.path.isdir(self.json_save_path):
            os.mkdir(self.json_save_path)
        with open(path, 'w') as f:
            json.dump(frames, f)
        self.json_data = frames
9118
def save(self, outfile):
        """"""
        if isinstance(outfile, compat.string_type):
            outfile = open(outfile, 'wb')
        assert hasattr(outfile, 'write') and callable(outfile.write), \
            "Expect a file or file-like object with a .write() method"
        outfile.write(self.data)
609719
function(url, outFile, cb, persist, headers) {
    this.file.save(
      outFile,
      request.get(
        {
          url : url,
          headers : headers
        }
      ),
      persist,
      cb
    );
  }
430101
def save
      if @id
        resource = self.class::RESOURCE % { account_id: account.id, id: id }
        response = Request.new(account.client, :put, resource, params: to_params).perform
      else
        resource = self.class::RESOURCE_COLLECTION % { account_id: account.id }
        response = Request.new(account.client, :post, resource, params: to_params).perform
      end
      from_response(response.body[:data])
    end