Skip to content
Snippets Groups Projects
Commit 173ff544 authored by Sebastian's avatar Sebastian
Browse files

added id, size and name to upload res

parent 307f1f11
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ AWS.config.update({
accessKeyId: process.env.AWS_ACCESS_KEY,
region: process.env.AWS_REGION,
})
// const fileName = Date.now().toString()
const AWSBackend = app => {
const authBearer = app.locals.passport.authenticate('bearer', {
session: false,
......@@ -31,20 +31,24 @@ const AWSBackend = app => {
bodyParser.json(),
upload.single('file'),
async (req, res) => {
try {
// console.log('FILE:', req.file)
const params = {
Bucket: process.env.AWS_BUCKET,
Key: req.file.originalname,
}
// console.log('FILE:', req.file)
const params = {
Bucket: process.env.AWS_BUCKET,
Key: req.file.originalname,
}
s3.getSignedUrl('getObject', params, (err, data) => {
if (err) throw err
res.status(200).json({ signedUrl: data })
s3.getSignedUrl('getObject', params, (err, data) => {
if (err) {
res.status(400).json({ error: err })
return
}
res.status(200).json({
id: req.file.etag.replace(/["]+/g, ''),
name: req.file.originalname,
size: req.file.size,
signedUrl: data,
})
} catch (e) {
res.status(400).json({ error: e })
}
})
},
)
}
......
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