如何使用nodejs将图像上传到s3时设置过期date

我想上传一个图片/video,并在nodejs sdk中设置到期date。 任何一个可以让我知道如何设置到期date,而上传图像到S3?

您可以使用multer-s3中间件进行快速configuration,然后您可以通过提供ExpiresCache-Controlmulter-s3configuration所需的标头。

 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!') })