Commit 77b3391e authored by Yannis Barlas's avatar Yannis Barlas

Merge branch 'awss3-extend' into 'master'

feat(aws-s3): add option to save files with new names

See merge request pubsweet/pubsweet!355
parents 489cc109 14e66e3f
Pipeline #8345 passed with stages
in 8 minutes and 39 seconds
......@@ -19,7 +19,8 @@ const setupMulter = s3 => {
metadata: (req, file, cb) => {
cb(null, {
FileType: get(req, 'body.fileType'),
FileName: get(file, 'originalname'),
FileName: get(req, 'body.newName', get(file, 'originalname')),
OriginalName: get(file, 'originalname'),
})
},
key: (req, file, cb) => {
......
const logger = require('@pubsweet/logger')
const get = require('lodash/get')
module.exports = async (req, res) => {
if (req.fileValidationError !== undefined) {
......@@ -9,7 +10,8 @@ module.exports = async (req, res) => {
return res.status(200).json({
id: req.file.key,
name: req.file.originalname,
originalName: get(req, 'file.originalname'),
name: get(req, 'file.metadata.FileName', get(req, 'file.originalname')),
size: req.file.size,
})
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment