upload file in Nodejs using s3 npm package

Issue

I am uploading video file using s3 bucket in Nodejs.

when I upload file on s3 bucket, it is also uploaded in temp/ folder. So after few video upload temp folder is become full due to this I can not upload more video.

How to remove this video from temp folder after file successfully or not upload on s3 bucket in Nodejs code?

I have used below package for s3 bucket.
https://www.npmjs.com/package/s3

Solution

var s3 = new AWS.S3();
s3.abortMultipartUpload(params, function (err, data) {
  if (err) console.log(err, err.stack); // USE BELOW CODE HERE
  else     console.log(data);           // ALSO HERE
});

Here is example of how can you remove/delete file from system using NodeJS

// include node fs module
var fs = require('fs');

// delete file named 'sample.txt'
fs.unlink('sample.txt', function (err) {
    if (err) throw err;
    // if no error, file has been deleted successfully
    console.log('File deleted!');
}); 

Answered By – sidgujrathi

Answer Checked By – Terry (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.