mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-14 11:50:31 +00:00
feat: getting presigned url of the uploaded attachment
This commit is contained in:
@@ -51,6 +51,12 @@ export class AttachmentsController extends BaseController {
|
||||
this.validationResult,
|
||||
this.unlinkDocument.bind(this)
|
||||
);
|
||||
router.get(
|
||||
'/:id/presigned-url',
|
||||
[param('id').exists()],
|
||||
this.validationResult,
|
||||
this.getAttachmentPresignedUrl.bind(this)
|
||||
);
|
||||
|
||||
return router;
|
||||
}
|
||||
@@ -185,4 +191,27 @@ export class AttachmentsController extends BaseController {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retreives the presigned url of the given attachment key.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param next
|
||||
*/
|
||||
private async getAttachmentPresignedUrl(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: any
|
||||
) {
|
||||
const { id: documentKey } = req.params;
|
||||
|
||||
try {
|
||||
const presignedUrl = await this.attachmentsApplication.getPresignedUrl(
|
||||
documentKey
|
||||
);
|
||||
return res.status(200).send({ presignedUrl });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user