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

Read Files

Once you get a file, whether through using filepicker.pick or from a standard <input type="file"/>, you can use this function to work with the contents.

Sample Code
/*Blob from a previous pick, etc.*/ var blob = { url: '', filename: 'hello.txt', mimetype: 'text/plain', isWriteable: true, size: 100 }; console.log("Loading "+blob.filename); blob, function(data){ console.log(data); } );
Sample Code
var input = document.getElementById("read-input"); var output = document.getElementById("read-result"); if (!input.value) { console.log("Choose an image to read below"); } else { input, {base64encode: true}, function(imgdata){ var img = document.createElement('img'); img.src = 'data:image/png;base64,'+imgdata; output.removeChild(output.firstChild); output.appendChild(img); console.log("Read successful"); }, function(fperror) { // console.log(FPError.toString()); - print errors to console } ); }

Choose image above

Syntax, [options], onSuccess(data){}, onError(FPError){}, onProgress(percent){})
input The object to read. Can be a Blob, a URL, a DOM File Object, or an <input type="file"/>.

An optional dictionary of key-value pairs that specify how the picker behaves:

Base64 Encoding

{base64encode: true}

Specify that you want the data to be retuned converted into base 64. This is very useful when the contents of the file are binary rather than text, for example with images. For your convenience, the filepicker.base64.encode and filepicker.base64.decode methods are available for your convenience.


{cache: true}

Whether the data should be pulled from the browser's cache, if possible. Defaults to false. Can make reads faster if you're sure the underlying file won't change.


{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 with the raw contents of the inputted file.


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

Possible error codes on the FPError:

111 Your browser doesn't support reading from DOM File objects
112 Your browser doesn't support reading from different domains
113 The website of the URL you provided does not allow other domains to read data
114 The website of the URL you provided had an error
115 File not found
118 General read error

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%.