add s3 deletion script
This commit is contained in:
parent
14d1c33951
commit
1e90ea1437
1 changed files with 13 additions and 0 deletions
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue