Sails.js File upload with Skipper to AWS S3
Instead of using skipper-s3
you can use the aws-sdk module. Upload the image to disk (original), process it, upload it, and delete the original.
var AWS = require('aws-sdk'),
fs = require('fs');
sharp(original).resize(800).quality(90).toBuffer(function(err, outputBuffer) {
if (err) {
...
} else {
new AWS.S3({
accessKeyId: 'your access key',
secretAccessKey: 'your secret',
params : {
Bucket : 'your bucket',
Key: 'desired filename'
}
});
s3client.upload({ACL:'public-read', Body: outputBuffer}, function(err, result) {
if(err) {
//handle error
} else {
// continue, handle returned data
fs.unlinkSync(original); // delete original
}
});
}
});
Alternatively, some libraries (like gm) can take a remote URL. You could use skipper-s3 to upload, then carry out the process above (where original is the s3 URL) and it would work, too—really not performant, at all, though.