我想在nodejs sdk中上传图像/视频并设置到期日期。 谁能告诉我如何在将图像上传到 s3 时设置到期日期?
最佳答案
You can use
multer-s3
middleware for express, and then you can configure the headers that you want by providing theExpires
,Cache-Control
headers.
const upload = multer({
storage: multerS3({
s3: s3,
bucket: 'some-bucket',
contentType: multerS3.AUTO_CONTENT_TYPE,
expires: 'Wed, 21 Oct 2020 07:28:00 GMT',
key: function (req, file, cb) {
cb(null, Date.now().toString())
}
})
})
app.post('/upload', upload.array('photos', 3), function(req, res, next) {
res.send('Successfully uploaded ' + req.files.length + ' files!')
})
关于node.js - 如何使用nodejs将图像上传到s3时设置到期日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46188908/