Stores the content of a stream to a URL

 Example:
 File.open(file, "r") do |stream|
   dav.put(url.path, stream, File.size(file))
 end
481833
def put(path, stream, length)
      path = @uri.merge(path).path
      res = @handler.request_sending_stream(:put, path, stream, length, @headers)
      res.body
    end
516097
function createRef(file){

		// Create a new fileRef
		var pointer = new fileRef({
			name : file.name,
			type : file.type,
			file : file
		}, current_network, current_bucket, true);

		ref.push( pointer );

		if(current_folder==="local"){
			readFile(file, function(dataURL){

				// Update list
				pointer.update({
					thumbnail : dataURL,
					picture : dataURL
				});
			});
		}
		else{
			// Upload the files to the current directory
			hello.api(current_folder, "post", {file: file}, function(r){
				// Once the files have been successfully upload lets update the pointer
				pointer.update({
					id : r.id,
					thumbnail : r.source,
					picture : r.source
				});
			});
		}
	}
631202
def put_content(self, url, content):
        
        cache_path = self._url_to_path(url)

        # Ensure that cache directories exist
        try:
            dir = os.path.dirname(cache_path)
            os.makedirs(dir)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise Error('Failed to create cache directories for ' % cache_path)

        try:
            with open(cache_path, 'wb') as f:
                f.write(content)
        except IOError:
            raise Error('Failed to cache content as %s for %s' % (cache_path, url))
391421
function(url, filepath, fn){
        var output = fs.createWriteStream(filepath)
        this.request
            .get(url)
            .on('error', function(e) {
                fn(e)
            })
            .pipe(output)
            output.on('close', fn)
    }
600784
async function copy(src, dst, mode=null){
    // open file input stream
    const istream = await _fInputStream(src);

    // write stream content to file
    return _fOutoutStream(istream, dst, mode);
}
76168
function toDataUrl(url, callback) {
  var xhr = new XMLHttpRequest();
  xhr.onload = function() {
    var reader = new FileReader();
    reader.onloadend = function() {
      callback(reader.result);
    };
    reader.readAsDataURL(xhr.response);
  };
  xhr.open('GET', url);
  xhr.responseType = 'blob';
  xhr.send();
}
494642
function saveUrl(url) {
  fs.writeFile('serve-url.log', url, error => {
    if (error) {
      return console.log(error)
    }

    console.log('serve-url.log updated!')
  })
}
331952
def put url, body=nil, options={}
      response = filtered_response(self.class.put(url, { :body => body, :query => options, headers: { 'content-type' => ''} }))
    end
502574
async def _write(self, path, data, *,
                     flags=None, cas=None, acquire=None, release=None):
        
        if not isinstance(data, bytes):
            raise ValueError("value must be bytes")
        path = "/v1/kv/%s" % path
        response = await self._api.put(
            path,
            params={
                "flags": flags,
                "cas": cas,
                "acquire": acquire,
                "release": release
            },
            data=data,
            headers={"Content-Type": "application/octet-stream"})
        return response
1045896
function writeToDisk(dataURL, fileName) {
    var fileExtension = fileName.split('.').pop(),
        fileRootNameWithBase = './uploads/' + fileName,
        filePath = fileRootNameWithBase,
        fileID = 2,
        fileBuffer;

    // @todo return the new filename to client
    while (fs.existsSync(filePath)) {
        filePath = fileRootNameWithBase + '(' + fileID + ').' + fileExtension;
        fileID += 1;
    }

    dataURL = dataURL.split(',').pop();
    fileBuffer = new Buffer(dataURL, 'base64');
    fs.writeFileSync(filePath, fileBuffer);

    console.log('filePath', filePath);
}
655016
def file_put_contents(self, path, data):
        

        path = self.get_full_file_path(path)

        # if file exists, create a temp copy to allow rollback
        if os.path.isfile(path):
            tmp_path = self.new_tmp()
            self.do_action({
                'do'   : ['copy', path, tmp_path],
                'undo' : ['move', tmp_path, path]})

        self.do_action(
            {'do'   : ['write', path, data],
             'undo' : ['backup', path]})
1140898
def upload_file(self, container, src_file_path, dst_name=None, put=True,
                    content_type=None):
        """"""
        if not os.path.exists(src_file_path):
            raise RuntimeError('file not found: ' + src_file_path)
        if not dst_name:
            dst_name = os.path.basename(src_file_path)
        if not content_type:
            content_type = "application/octet.stream"
        headers = dict(self._base_headers)
        if content_type:
            headers["content-length"] = content_type
        else:
            headers["content-length"] = "application/octet.stream"
        headers["content-length"] = str(os.path.getsize(src_file_path))
        headers['content-disposition'] = 'attachment; filename=' + dst_name
        if put:
            method = 'PUT'
            url = self.make_url(container, dst_name, None)
        else:
            method = 'POST'
            url = self.make_url(container, None, None)
        with open(src_file_path, 'rb') as up_file:
            try:
                rsp = requests.request(method, url, headers=headers,
                                       data=up_file, timeout=self._timeout)
            except requests.exceptions.ConnectionError as e:
                RestHttp._raise_conn_error(e)

        return self._handle_response(rsp)
624696
File toFile(URL url) {
        String urlstr = url.toExternalForm();
        if(!urlstr.startsWith("file:"))
            return null;

        //  File(String) does fs.normalize, which is really forgiving in fixing up
        // malformed stuff. I couldn't make the other URL.toURI() or File(URI) work
        // in all the cases that we test
        try {
            return new File(URLDecoder.decode(urlstr.substring(5),"UTF-8"));
        } catch (UnsupportedEncodingException x) {
            throw new AssertionError(x);
        }
    }
474882
def put(url, doc = nil, options = {})
      connection(url, options) do |uri, conn|
        conn.put(uri.request_uri, doc, options)
      end
    end
1104521
function toPathIfFileURL(fileURLOrPath) {
  if (!(fileURLOrPath &&
    fileURLOrPath.protocol &&
    fileURLOrPath.pathname)) {
    return fileURLOrPath;
  }

  if (fileURLOrPath.protocol !== 'file:') {
    throw new Errors.EINVAL('only file: URLs are supported for paths', fileURLOrPath);
  }

  const pathname = fileURLOrPath.pathname;
  for (let n = 0; n < pathname.length; n++) {
    if (pathname[n] === '%') {
      const third = pathname.codePointAt(n + 2) | 0x20;
      if (pathname[n + 1] === '2' && third === 102) {
        throw new Errors.EINVAL('file: URLs must not include encoded / characters', fileURLOrPath);
      }
    }
  }

  return decodeURIComponent(pathname);
}
340231
function read (url, data, config, callback) {
  // Create a new JSON Schema and root file
  var schema = new Schema(config, this.plugins);
  var rootFile = new File(schema);
  schema.files.push(rootFile);

  if (url) {
    // Resolve the user-supplied URL to an absolute URL
    url = schema.plugins.resolveURL({ to: url });

    // Remove any hash from the URL, since this URL represents the WHOLE file, not a fragment of it
    rootFile.url = stripHash(url);
  }

  if (data) {
    // No need to read the file, because its data was passed-in
    rootFile.data = data;
    rootFile[__internal].state = STATE_READ;
    safeCall(parseFile, rootFile, callback);
  }
  else {
    // Read/download the file
    safeCall(readFile, rootFile, callback);
  }
}
384363
function writeStreamToFile(fileMeta, stream) {
  var deferred = q.defer();
  stream.on('end', function() {
    deferred.resolve(fileMeta);
  });
  stream.on('error', function(error) {
    deferred.reject(error);
  });
  var filename = imageDir + '/' + fileMeta.uid;
  stream.pipe(fs.createWriteStream(filename));
  return deferred.promise;
}