Skip to content

Commit 6b25df7

Browse files
committed
fix: attachment download url
1 parent 0dec8fc commit 6b25df7

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/routes/attachments/get.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,20 @@ const permissions = tcMiddleware.permissions;
1919
* @returns {Array<Promise>} The array of two promises, first one if the attachment object promise,
2020
* The second promise is for the file pre-signed url (if attachment type is file)
2121
*/
22-
const getPreSignedUrl = (req, attachment) => {
22+
const getPreSignedUrl = async (req, attachment) => {
23+
// If the attachment is a link return it as-is without getting the pre-signed url
2324
if (attachment.type === ATTACHMENT_TYPES.LINK) {
24-
// If the attachment is a link return it as-is without getting the pre-signed url
2525
return [attachment, ''];
26-
} // The attachment is a file
27-
// In development/test mode, if file upload is disabled, we return the dummy attachment object
28-
if (_.includes(['development', 'test'], process.env.NODE_ENV) && config.get('enableFileUpload') === 'false') {
26+
}
27+
28+
// The attachment is a file
29+
// In development mode, if file upload is disabled, we return the dummy attachment object
30+
if (_.includes(['development'], process.env.NODE_ENV) && config.get('enableFileUpload') === 'false') {
2931
return [attachment, 'dummy://url'];
3032
}
31-
// Not in development mode or file upload is not disabled
32-
return [attachment, util.getFileDownloadUrl(req, attachment.path)];
33+
// Not in development mode or file upload is not disabled
34+
const url = await util.getFileDownloadUrl(req, attachment.path);
35+
return [attachment, url];
3336
};
3437

3538
module.exports = [

0 commit comments

Comments
 (0)