const deleteFilesFromS3 = async (fileKeys) => {
const s3 = new aws.S3({
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey,
region: region,
});
// Iterate through fileKeys and delete each file from S3
for (const fileKey of fileKeys) {
const params = {
Bucket: "thenaturebeautyflower",
Key: fileKey,
};
try {
await s3.deleteObject(params).promise();
console.log(`File deleted successfully: ${fileKey}`);
} catch (error) {
console.error(`Error deleting file from S3: ${fileKey}`, error);
}
}
};
字符串
文件删除成功:https://thenaturebeautyflower.s3.ap-south-1.amazonaws.com/pool/images/%20BERL%C3%8DN%20filter-1702962944491-3-Berlin.jpg ProductState.js:156文件删除成功:https://thenaturebeautyflower.s3.ap-south-1.amazonaws.com/pool/pdf/%20BERL%C3%8DN%20filter-1702962944491-BERLIN.pdf
但仍然图像和pdf文件是目前在s3控制台?
1条答案
按热度按时间cunj1qz11#
字符串
我的错误是,我是puuting完整的地址在filname下的参数,这是错误的,我们应该只包含一个文件夹/filaname. extension只