我想上传一张图片/视频,并在nodejs sdk中设置过期日期。有没有人可以告诉我在上传图片到s3时如何设置过期日期?
发布于 2017-09-13 05:09:35
你可以使用
multer-s3
中间件来表达,然后你可以通过提供Expires
,Cache-Control
头来配置你想要的头。
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!')
})
发布于 2020-07-08 08:17:00
您可以通过权限设置s3存储桶的过期时间。在您的存储桶中,转到管理,然后转到生命周期,开始一个新的生命周期,并将到期时间(阶段3)设置为您想要的天数。
虽然它不是一个sdk解决方案,但我希望它能有所帮助。
https://stackoverflow.com/questions/46188908
复制相似问题