const S3Unzip = require('s3-unzip');
exports.handler = function(event, context, callback) {
const bucketname = event.Records[0].s3.bucket.name;
const filename = decodeURIComponent(event.Records[0].s3.object.key.replace(/+/g, ' '));
new S3Unzip({
bucket: bucketname,
file: filename ,
verbose: true,
}, function(err, success) {
if (err) {
callback(err);
} else {
callback(null);
}
});
}
This is the lambda function code that I’m currently using to unzip the zip files in my s3 bucket.
My requirement is to rename the unzipped files before uploading to s3 bucket, how should I modify the above code to achieve this?
`
I tried using other packages like unzipper which require a filesystem to unzip and then I will be able to rename the filenames of each file. But I don’t want to do that. I’m looking if it is possible by using the s3-unzip package itself.
akhil office is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.