duplicate is probably less broken than it was

This commit is contained in:
Cassie Tarakajian 2017-05-13 21:17:58 -04:00
parent 517045623c
commit 3c6049ceef
1 changed files with 3 additions and 2 deletions

View File

@ -89,13 +89,14 @@ export function copyObjectInS3(req, res) {
const objectKey = getObjectKey(url);
const fileExtension = getExtension(objectKey);
const newFilename = uuid.v4() + fileExtension;
const userId = req.user.id;
const params = {
Bucket: `${process.env.S3_BUCKET}`,
CopySource: `${process.env.S3_BUCKET}/${objectKey}`,
Key: newFilename
Key: `${userId}/${newFilename}`
};
const copy = client.copyObject(params);
copy.on('end', () => {
res.json({ url: `${s3Bucket}${newFilename}` });
res.json({ url: `${s3Bucket}${userId}/${newFilename}` });
});
}