File Export (Save To) - Export a File to Cloud Service

When a user creates content in your application, generates a report, or finds something that they want to save for later, you can allow them to send that content directly to dropbox, google drive, evernote, or even send it via email.

The Filestack javascript library allows you to accomplish this easily with only a few lines of code.

Export is basically the opposite of filepicker.pick, in that it takes a Blob and lets the user specify where to send it to.

Syntax

<script src="https://api.filestackapi.com/filestack.js"></script>
<script type="text/javascript">
  filepicker.setKey("your_API_KEY");
  filepicker.exportFile(input, picker_options, onSuccess(Blob){}, onError(FPError){}, onProgress(FPProgress){});
</script>

Example Export Code - Url file export

Launch export dialog using Filestack URL and suggested filename
filepicker.exportFile( 'https://www.filestackapi.com/api/file/qHi4LxRh28IeEBdJcFpw', { mimetype:'image/jpeg', suggestedFilename: 'newFile' }, function(Blob){ console.log(Blob.url); } );

Example Export Code - Blob file export

Launch export dialog using Filestack Blob with default filename
var blob = { url: 'https://www.filestackapi.com/api/file/AMltoa8ATECOsFTMduLz', filename: 'hello.txt', mimetype: 'text/plain', isWriteable: true, size: 100 }; filepicker.exportFile( blob, function(Blob){ console.log(Blob.url); } );
input
the file to export
input
string or blob
{Filestack Blob or URL}

A Blob or URL pointing to data you'd like to export. If you have a DOM File object or raw data, you can use the filepicker.store call to first generate a Blob

picker_options
An optional dictionary of key-value pairs that specify how the picker behaves.
Container
String
{container: 'modal'}

Where to load the Filestack UI into. Possible values are "window", "modal", or the id of an iframe in the current document. Defaults to "modal" for desktop browsers and 'window' for mobile browsers.

Mimetype
String
{mimetype: 'image/png'}

The mimetype of the file. Note that we try to guess the file extension of the file from this, so image/png will result in a .png ending while image/* will not have an ending. If you don't specify the mimetype, we will try to guess, otherwise we will fall back to letting the user save the file as whatever extension they choose, which may cause issues (if they try to save text to Facebook, for instance).

Extension
String
{extension: '.pdf'}

The extension of the content you want the user to save. Like mimetype, this is used to suggest a filename and prevent the file from being saved to services that don't support it (Sending text to Facebook, for instance). Do not use both extension and mimetype at the same time.

Filename
String
suggestedFilename: 'newFile'}

Provide a recommended file name. The user will always be able to overwrite but you'll be able to set the default name.

Services
String
{service: 'FACEBOOK'}
{services: ['FACEBOOK','BOX',…]}

Specify which services are displayed on the left panel, and in which order, by name.

Be sure that the services you select are compatible with the mimetype(s) or extension(s) specified.

Currently, Filestack supports the following services, and we're adding more all the time:

  • BOX
  • COMPUTER
  • DROPBOX
  • EVERNOTE
  • FACEBOOK
  • FLICKR
  • FTP
  • GOOGLE_DRIVE
  • SKYDRIVE
  • PICASA
  • SEND_EMAIL
  • ALFRESCO
  • CLOUDDRIVE
  • IMGUR
  • CLOUDAPP
For all new applications, it is required to set your own Dropbox OAuth keys in order to use the Dropbox service with Filestack. More info

The COMPUTER service should be specified if you want users to be able to select files from their local device (their desktop or mobile device). To learn more about local file uploads Click Here

Default Service
String
{openTo: 'BOX'}

Specifies which service to show upon opening the picker dialog.

Language
String
{language: 'es'}

Specify the filestack dialog language version. If not set, it will use language detected in the browser. If the detected language is unavaliable, the default value is 'en'.

Supported languages:

  • Czech: 'cs'
  • German: 'de'
  • English: 'en'
  • Spanish: 'es'
  • Spanish (Mexican): 'es_mx'
  • Faroese: 'fo'
  • French: 'fr'
  • Canadian French: 'fr_ca'
  • Hebrew: 'he'
  • Italian: 'it'
  • Dutch: 'nl'
  • Danish: 'da'
  • Norwegian: 'no'
  • Polish: 'pl'
  • Portuguese: 'pt'
  • Portuguese (Brazilian): 'pt_br'
  • Russian: 'ru'
  • Swedish: 'sv'
  • Turkish: 'tr'
  • Chinese (Taiwan): 'zh_tw'
  • Greek: 'el'
  • Spanish (Argentina): 'es_ar'
  • Finnish: 'fi'
  • Indonesian: 'id'
  • Korean: 'ko'
  • Slovak: 'sk'
  • Ukrainian: 'uk'
  • Chinese: 'zh'
  • Serbian: 'sr'
  • Bulgarian: 'bg'
  • Malay: 'ms'
  • Hungarian: 'hu'
  • Vietnamese: 'vi'

If you would like to co-create the translation to any language, please contact us.

Security
Object
{policy: POLICY, signature: SIGNATURE}

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

Custom CSS
String
{customCss: '//domain.com/link_to_your_css.css'}

Use a custom CSS file to customize the appearance of each dialog instance. You can also set this option globally in the developer portal so the same CSS is used for all dialog instances. The URL of your CSS file should use the https protocol and be publicly accessible. To learn more about customizing the upload dialog click here. The customCss parameter and global setting are only available on paid Filestack plans.

Custom Dialog Text
String
{customText: '//domain.com/your_json_file.json'}

Allows a user to provide their own text for the Filestack dialog. The URL of your JSON file should use https protocol and be publicly accessible. Here is a sample JSON file including the English text for the dialog that can be used as a base for your custom text: English_Dialog_Text.JSON Your custom text must include all the keys present in this file. The values can be blank if you choose. Other language files are available by using the language code to modify the url linking to this French translation file, so es.js for Spanish, ru.js for Russian, pl.js for Polish, etc. The sample French file above contains variables that look like this: __variable__, however in order to work with the customText picker option, these variables must adhere to this format: {{variable}}.