Store a File with the REST API

Similar to the filepicker.store call in javascript, you can use the Filepicker files library to send files directly to your S3 bucket (or other cloud storage) and get back a Blob for further operations. To do this, issue a POST to the /api/store/S3 endpoint (can also be gcs, azure, rackspace or dropbox), along with your apikey, the file, and any optional parameters you want to include.

Syntax

Request:
>>> curl -X POST -F fileUpload=@filename.txt "https://www.filestackapi.com/api/store/S3?key=MY_API_KEY"
Result:
{"url": "https://www.filestackapi.com/api/file/HLOon3NcTS6w7rqyZ3ei", "size": 234, "type": "text/plain", "filename": "tester.txt", "key": "1ilWxmaRRqhMd2vSbSyB_tester.txt"}

Request:
>>> curl -X POST -d url="https://d3urzlae3olibs.cloudfront.net/watermark.png" https://www.filestackapi.com/api/store/S3?key=MY_API_KEY
Result:
{"url": "https://www.filestackapi.com/api/file/s7tdGfE5RRKFUxwsZoYv", "size": 8331, "type": "image/png", "filename": "watermark.png", "key": "a1RyBxiglW92bS2SRmqM_watermark.png"}

Request:
>>> curl  -X POST  -d  url="https://d3urzlae3olibs.cloudfront.net/watermark.png"  "https://www.filestackapi.com/api/store/S3?key=AhTgLagciQByzXpFGRI0Az&path=/myfiles/1234.png&mimetype=image/png"
Result:
{"container": "custom_source", "url": "https://www.filestackapi.com/api/file/rLNF34IvRWybiNIATg4D", "filename": "watermark.png", "key": "myfiles/1234.png", "type": "image/png", "size": 8331}

If you set additional REST parameters make sure that the URL is given in quotes.

options
https://www.filestackapi.com/api/store/[store_location]?key=MY_API_KEY&[options]
Store Location
String
{S3, gcs, azure, rackspace, dropbox}

Set the store parameter directly after the slash /api/store/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.

Filename
String
{filename=MyCoolPhoto.png}

The name of the file as it will be stored. If this isn't provided, we do the best we can to come up with one.

Mimetype
String
{mimetype=text/html}

The type of the file as it will be stored. If this isn't provided, we do the best we can, defaulting to "text/plain" if you give us raw data.

Path
String
{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".

Container
String
{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 that this parameter does not apply to the Dropbox file store.

Public Access
String
{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'.

Base64 Decoding
Boolean
{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.

Security
String
{policy=POLICY&signature=SIGNATURE}

If you have security enabled, you'll need to have 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