feat(assets): add ?redirect=1 to thumbnail endpoint for img src use
This commit is contained in:
parent
36e668455f
commit
a5823effe9
1 changed files with 4 additions and 1 deletions
|
|
@ -483,7 +483,7 @@ router.get('/:id/video', async (req, res, next) => {
|
|||
} catch (err) { next(err); }
|
||||
});
|
||||
|
||||
// GET /:id/thumbnail - Signed URL for thumbnail image
|
||||
// GET /:id/thumbnail - Signed URL (JSON) or 302 redirect (?redirect=1) for thumbnail
|
||||
router.get('/:id/thumbnail', async (req, res, next) => {
|
||||
try {
|
||||
const { id } = req.params;
|
||||
|
|
@ -503,6 +503,9 @@ router.get('/:id/thumbnail', async (req, res, next) => {
|
|||
}
|
||||
|
||||
const url = await getSignedUrlForObject(thumbnail_s3_key);
|
||||
|
||||
// ?redirect=1 lets <img src="...thumbnail?redirect=1"> work directly in the browser
|
||||
if (req.query.redirect === '1') return res.redirect(302, url);
|
||||
res.json({ url });
|
||||
} catch (err) {
|
||||
next(err);
|
||||
|
|
|
|||
Loading…
Reference in a new issue