Search code examples
amazon-web-servicesamazon-s3sails.jssails-skipper

How can I delete a file in AWS S3 with Sails? To upload, I use skipper-s3


I just made an upload file to AWS S3 with sails and skipper-3 and it work well. Now, how can I delete a file in AWS S3 with Sails?

When I upload the file I store in the Database the URL to AWS S3.


Solution

  • You can use AWS-SDK directly or one of the many wrappers to it available at npm.

    Based on Amazon documentation you will have something like:

    s3.deleteObject(params, function(err, data) {
        if (err) console.log(err, err.stack);  // error
        else     console.log();                 // deleted
    });
    

    paramsshall hold parameters as bucket, credentials, region, path. See the example at Amazon nodejs examples.

    And, for sure you can use the AWS SDK for upload files and use other AWS services inside sails too.

    Your question is answered here too.