Upload a File Directly to S3 Using Multi-Part Chunking

Use Filestack's brand new upload API (the same used in the picker) to upload files without the picker interface.

Please Note: The upload function will not work without an API key. To initialize the client use filestack.init("yourApiKey"). Filestack's documentation examples include a key in the background, but if you want to test something using your own key, you can always add var client = filestack.init("yourApiKey"); to the live code examples.


The javascript upload function can be called at anytime to upload a file once the client has been initialized. You may pass in an optional dictionary of key-value pairs to customize the behavior of the upload.

Note: Security policies and signatures should be included as options when the client is initialized with your API key if your account has security enabled.

<script src="https://static.filestackapi.com/v3/filestack-0.4.1.js"></script>
<script type="text/javascript">
  var client = filestack.init('yourApiKey', { policy: 'policy', signature: 'signature' });
  client.upload(file, uploadOptions, storeOptions);

Example Upload Code - Store a PNG from an input field

Use a standard input field and then upload the selected file object
var log = function(result) { console.log(JSON.stringify(result)) } var input = document.getElementById("store-input"); if (!input.value) { console.log("Choose a png to store to S3"); } else { client.upload(input.files[0]).then(log) }


Client Initialization Options
An optional dictionary of key-value pairs that influence the Filestack client.
{ policy: POLICY, signature: SIGNATURE }

If you have security enabled, you will need to initialize the client with a valid Filestack 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 File to store
File or Blob

Must be a valid File or Blob.

An optional dictionary of key-value pairs that specify how Filestack uploads files.
Part Size
partSize: 5 * 1024 * 1024

Size of each uploaded part in bytes. Minimum accepted value is 5Mb

Max Concurrent Uploads
maxConcurrentUploads: 5

Max number of chunks the client should try to upload at one time

Retry Options
retryOptions: { parameter: value }

An optional dictionary of key-value pairs that dictate how the client should retry failed uploads. Possible options are:

retries: 10 Sets the max number of retries for failed chunks. This parameter should be an integer.
factor: 2 The exponential factor to use. The value for this parameter should be an integer.
minTimeout: 1 * 1000 Set the number in milliseconds for how long to wait before starting the first retry.
maxTimeout: 60 * 1000 Set the number in milliseconds for the max amount of time to wait between two retries.

Called when the flow begins (before the Filestack handshake request is made).


Called when an upload begins (after S3 request is made).


Called on progress event.


Called if upload fails and retry is occurring.


Called when an upload is completing (before final completion request).

An optional dictionary of key-value pairs that specify how Filestack stores files.
location: 's3'

Where to store the file. The default is 's3'. Other options are 'azure', 'dropbox', 'rackspace' and 'gcs'. You must have configured your storage in the developer portal to enable this feature. Note: Rackspace, Azure, Dropbox and Google Cloud are only available on the Grow and higher plans.

path: '/myfiles/1234.png'

The path to store the file at within the specified file store. For S3, this is the key where the file will be stored at. By default, Filestack stores the file at the root at a unique id, followed by an underscore, followed by the filename, for example "3AB239102DB_myphoto.png".

If the provided path ends in a '/', it will be treated as a folder, so if the provided path is "myfiles/" and the uploaded file is named "myphoto.png", the file will be stored at "myfiles/909DFAC9CB12_myphoto.png", for example.

container: 'user-photos'

The bucket or container in the specified file store where the file should end up. This is especially useful if you have different containers for testing and production and you want to use them both on the same Filestack app. If this parameter is omitted, the file is stored in the default container specified in your developer portal.

Note: This parameter does not apply to the Dropbox file store.

region: 'us-east-1'

The region where your storage container is located. This setting currently applies only to S3 buckets. If you are using a different bucket and region than the one you set up in your developer portal you can pass the region as part of your store options. If this parameter is not set we will do our best to determine the region your S3 bucket is located so that we can properly authenticate our connection request. You can find a list of the S3 regions here: in the "region" column.

Public Access
access: 'public'

Indicates that the file should be stored in a way that allows public access going directly to the underlying file store. For instance, if the file is stored on S3, this will allow the S3 url to be used directly. This has no impact on the ability of users to read from the Filestack file URL. Defaults to 'private'.