move file from one folder to another in aws s3 nodejs

Solutions on MaxInterview for move file from one folder to another in aws s3 nodejs by the best coders in the world

showing results for - "move file from one folder to another in aws s3 nodejs"
Jaxon
02 May 2019
1var AWS = require('aws-sdk');
2AWS.config.update({
3     accessKeyId: 'xxx',
4     secretAccessKey: 'xxx'
5    });
6var s3 = new AWS.S3();
7var params = {
8    Bucket : 'bucketname', /* Another bucket working fine */ 
9    CopySource : 'bucketname/externall/1.txt', /* required */
10    Key : "1.txt", /* required */
11    ACL : 'public-read',
12};
13s3.copyObject(params, function(err, data) {
14    if (err)
15        console.log(err, err); // an error occurred
16    else {
17        console.log(data); // successful response
18    }
19});