【发布时间】:2019-05-16 10:10:55
【问题描述】:
在我的 express 应用程序中,我将图像保存到我的仓库中的一个文件夹中。
但是我认为这是不正确的,我应该将它们存储在其他地方,我认为 s3 会是一个不错的选择。
我以前从未做过,所以我不知道它是如何工作的。
我当前的代码在缩放后保存图像:
exports.resize = async (req, res, next) => {
// check if there is no new file to resize
if (!req.file) {
next(); // skip to the next middleware
return;
}
const extension = req.file.mimetype.split('/')[1]
req.body.photo = `${uuid.v4()}.${extension}`
// now we resize
const photo = await jimp.read(req.file.buffer)
await photo.cover(300, 300);
// await photo.resize(800, jimp.AUTO);
await photo.write(`./public/uploads/${req.body.photo}`);
// once we have written the photo to our filesystem, keep going!
next()
};
将图像保存到 aws s3 的过程是什么?
谢谢
【问题讨论】:
标签: javascript node.js express amazon-s3