|
|
@ -58,34 +58,28 @@ export class AttachmentsService { |
|
|
|
icon: mimeIcons[path.extname(originalName).slice(1)] || undefined, |
|
|
|
icon: mimeIcons[path.extname(originalName).slice(1)] || undefined, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const promises = []; |
|
|
|
|
|
|
|
// if `url` is null, then it is local attachment
|
|
|
|
// if `url` is null, then it is local attachment
|
|
|
|
if (!url) { |
|
|
|
if (!url) { |
|
|
|
// then store the attachment path only
|
|
|
|
// then store the attachment path only
|
|
|
|
// url will be constructed in `useAttachmentCell`
|
|
|
|
// url will be constructed in `useAttachmentCell`
|
|
|
|
attachment.path = `download/${filePath.join('/')}/${fileName}`; |
|
|
|
attachment.path = `download/${filePath.join('/')}/${fileName}`; |
|
|
|
|
|
|
|
|
|
|
|
promises.push( |
|
|
|
attachment.signedPath = await PresignedUrl.getSignedUrl({ |
|
|
|
PresignedUrl.getSignedUrl({ |
|
|
|
path: attachment.path.replace(/^download\//, ''), |
|
|
|
path: attachment.path.replace(/^download\//, ''), |
|
|
|
}); |
|
|
|
}).then((r) => (attachment.signedPath = r)), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (attachment.url.includes('.amazonaws.com/')) { |
|
|
|
if (attachment.url.includes('.amazonaws.com/')) { |
|
|
|
const relativePath = decodeURI( |
|
|
|
const relativePath = decodeURI( |
|
|
|
attachment.url.split('.amazonaws.com/')[1], |
|
|
|
attachment.url.split('.amazonaws.com/')[1], |
|
|
|
); |
|
|
|
); |
|
|
|
promises.push( |
|
|
|
|
|
|
|
PresignedUrl.getSignedUrl({ |
|
|
|
attachment.signedUrl = await PresignedUrl.getSignedUrl({ |
|
|
|
path: relativePath, |
|
|
|
path: relativePath, |
|
|
|
s3: true, |
|
|
|
s3: true, |
|
|
|
}).then((r) => (attachment.signedUrl = r)), |
|
|
|
}); |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await Promise.all(promises); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
attachments.push(attachment); |
|
|
|
attachments.push(attachment); |
|
|
|
}), |
|
|
|
}), |
|
|
|
); |
|
|
|
); |
|
|
|