View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page

Uploading to Amazon S3

Please note that your Amazon S3 bucket must be created in the 'US Standard' region. If you fail to do so, you will get a 'TypeError('Uncaught, unspecified "error" event.').

With Sails, you can stream file uploads to Amazon S3 with very little additional configuration.

First install the S3 Skipper adapter:

$ npm install skipper-s3 --save

Then use it in one of your controllers:

uploadFile: function (req, res) {
    req.file('avatar').upload({
      adapter: require('skipper-s3'),
      key: 'S3 Key'
      secret: 'S3 Secret'
      bucket: 'Bucket Name'
    }, function (err, filesUploaded) {
      if (err) return res.negotiate(err);
      return res.ok({
        files: filesUploaded,
        textParams: req.params.all()
      });
    });
  }

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.