add s3 deletion script

This commit is contained in:
Cassie Tarakajian 2016-12-13 20:45:30 -05:00
parent 14d1c33951
commit 1e90ea1437

View file

@ -62,6 +62,19 @@ objectsResponse.on('end', () => {
// console.log("would delete file: ", fileKey); // console.log("would delete file: ", fileKey);
} }
}); });
let params = {
Bucket: `${process.env.S3_BUCKET}`,
Delete: {
Objects: filesToDelete,
},
};
let del = client.deleteObjects(params);
del.on('err', (err) => {
console.log(err);
});
del.on('end', () => {
console.log('deleted extra S3 files!');
});
console.log("To delete: ", filesToDelete.length); console.log("To delete: ", filesToDelete.length);
console.log("Total S3 files: ", uploadedFiles.length); console.log("Total S3 files: ", uploadedFiles.length);
console.log("Total S3 files in mongo: ", s3Files.length); console.log("Total S3 files in mongo: ", s3Files.length);