I want to upload an image to S3, but I need it to be converted first. How can I use Filestack to achieve this?

If you only need the converted file, you can try this workflow:
  1. Use the pick method to get the original image
  2. Use the convert method to transform the image (this automatically saves a new copy and creates a new Filestack link)
  3. Remove the original image
Here is what the code for this might look like:
Pick with nested conversion function and remove for cleanup of original file
filepicker.pick({ mimetypes: ['image/*'], services: ["COMPUTER","GOOGLE_DRIVE","FACEBOOK"] }, function(pickedBlob) { // convert a file filepicker.convert( pickedBlob, // conversion options { width: 200, height: 200 }, // store options { location: 'S3' }, function(convertedBlob) { // Converted file url console.log("Converted file url: ", convertedBlob.url); // File is stored under your S3 console.log("File is stored at the following key in S3: ", convertedBlob.key); result.src = convertedBlob.url; // If you no longer need the original file - remove it filepicker.remove( pickedBlob, { policy: 'eyJleHBpcnkiOjE2ODgxMzkwNTJ9', signature: '5f66059fcacd65298ea55f66bf005f73688534632f20e77c5b1f0ac69d1c0286' }, function() { console.log("Removed"); } ); }, function(FPError) { console.log(FPError.toString()); } ); }, function(FPError) { console.log(FPError.toString()); } );

Another alternative (if the source image has a URL) would be to use our REST Transformation API to convert the image and then store the result in one action.

For example:

Store CURL Request with External URL
>>> curl -X POST -g "https://process.filestackapi.com/AuSv4FudVRheqTxmY0NDgz/store=container:filestack-web-demo,location:S3,region:us-east-1,path:\"my/custom/path/\",filename:custom_flower_crop.jpg/crop=dim:[301,269,1226,1100]/monochrome/https://d1wtqaffaaj63z.cloudfront.net/images/P5305990_resized.jpg"

The response you receive will be like the standard JSON blob Filestack returns after using the filepicker.store() method.

returned JSON blob:


Stored, cropped and desaturated image:

image transformed with the crop and monochrome tasks and stored as a new image