Actually am unzipping the folders to buffer from s3 bucket.Then upload the folders from buffer to another s3 bucket.Kindly help me how to provide the params for s3 putobject to upload a folder.
This is my code.
var folderName = '';
function UnzipAndUpload() {
async.waterfall([
function download(next) {
s3.getObject(params, function (err, data) {
next(err, data);
});
},
function gunzip(response, next) {
var buffer = new Buffer(response.Body);
zlib.gunzip(buffer, function (err, decoded) {
folderName = decoded.toString(); //Folders
next(err, decoded && decoded.toString());
});
},
function Upload(data, next) {
UploadDataToS3(data, folderName);
// context.done();
}
], function (err) {
if (err) throw err;
});
}
function UploadFilestoS3(data, folderName ) {
var extractedData = data;
s3.putObject({
Bucket: bucketName,
Key: "", //What key name has to give for folders
Body: extractedData,
}, function (err) {
console.log('uploaded file: ');
});
}
via vishnu
No comments:
Post a Comment