Getting Started

Filestack Architecture

File Upload

File Export (Save To)

Responsive Images

Image Transformations

Document Transformations

Video Transcoding

Audio Transcoding





Filestack Viewer


Supported Cloud Drives

Filestack Recipes

Filestack Integrations

Filestack SDKs

Register for an API key

Write a Blob Back to a File - Overwrite an existing Filestack Link with a New File

Once you get a file via filepicker.pick or, you can write directly back to it - full filesystem operation in javascript!

Sample Code
/*Blob from a previous pick, etc.*/ var blob = { url: '', filename: 'rewrite_me.txt', mimetype: 'text/plain', isWriteable: true, size: 100 }; console.log("Writing to "+blob.filename + "..."); filepicker.write( blob, "Filepicker rocks the Hello World", function(Blob){ console.log(replaceHtmlChars(JSON.stringify(Blob))); }, function(FPError) { // console.log("Error: "+FPError.toString()); - print errors to console } );
Sample Code
var blob = { url: '', filename:"robot.png", mimetype:"image/png", size:28683, isWriteable:true }; var input = document.getElementById("write-input"); if (!input.value) { console.log("Choose a png to write to the file"); } else { filepicker.write( blob, input, function(Blob){ console.log("Write successful:", Blob.filename); }, function(FPError) { // console.log(FPError.toString()); - print errors to console }, function(progress) { console.log("Loading: "+progress+"%"); } ); }


filepicker.write(target, data, [options], onSuccess(Blob){}, onError(FPError){}, onProgress(percent){})
target A Blob pointing to the file you'd like to write to. Note that if the Blob was pulled from a user's cloud storage service (Dropbox, etc.), the write will directly modify the file in their cloud storage. If the Blob was generated by a store operation or loaded from the user's computer, the write will edit the stored copy.

The data to write to the target file, or an object that holds the data. Can be raw data, a Blob, a DOM File Object, or an <input type="file"/>.


An optional dictionary of key-value pairs that configure the write

Base64 Decoding

{base64decode: true}

Specify that you want the data to be first decoded from base64 before being written to the file. For example, if you have base64 encoded image data, you can use this flag to first decode the data before writing the image file.


{policy: POLICY, signature: SIGNATURE}

If you have security enabled, you'll need to have a valid policy and signature in order to perform the requested call. This allows you to select who can and cannot perform certain actions on your site. Read more about security and how to generate policies and signatures


The function to call if the write is successful.

We'll return a Blob as a JSON object with the following properties.

url The core Filestack file url on which all other operations are based.
filename The filename of the uploaded file.
mimetype The mimetype of the uploaded file.
size The size of the uploaded file in bytes, if available.
isWriteable Whether the file can be written to using filepicker.write.

The function to call if there is an error when writing the file.

Possible error codes on the FPError:

111 Your browser doesn't support reading from DOM File objects
115 File not found
118 General read error
121 The Blob to write to could not be found

For more info about FPErrors, see Error Handling.


The function that is called on progress events, if available. The function is called with the percent completed as a number out of 100.

Note that on older browsers, particularly IE 8 and IE 9, the browser does not provide progress events and therefore onProgress will not be called except at 100%.