此代码段通过提供图像名称作为输入来生成AWS s3的图像URL。我有一个要生成的图像名称数组,因此现在我循环该代码。但是对于某些人来说,生成URL花费了太多时间。图片网址是mssing。是否有其他本机解决方案?
let folder = data;
try {
const listPhotos = await s3.listObjects({
Bucket: bucket_name,
Delimiter: folder,
Prefix: folder
}).promise();
if (listPhotos.Contents.length) {
let params = {
Bucket: bucket_name,
Key: folder,
Expires: 86400
}
let orginalImageUrl = await s3.getSignedUrl('getObject', params);
//console.log("-----",orginalImageUrl);
return orginalImageUrl;
} else {
let orginalImageUrl = "no image";
return {ImageURL: orginalImageUrl};
}
} catch (e) {
return e
}