feat: image endpoint
This commit is contained in:
parent
e0184631da
commit
1f54d5d1df
1 changed files with 2 additions and 1 deletions
|
|
@ -125,11 +125,12 @@ export class ProductController extends Controller {
|
||||||
@Get("{productId}/image")
|
@Get("{productId}/image")
|
||||||
async getProductImageById(@Request() req: RequestWithUser, @Path() productId: string) {
|
async getProductImageById(@Request() req: RequestWithUser, @Path() productId: string) {
|
||||||
const url = await presignedGetObjectIfExist(MINIO_BUCKET, imageLocation(productId), 60 * 60);
|
const url = await presignedGetObjectIfExist(MINIO_BUCKET, imageLocation(productId), 60 * 60);
|
||||||
|
|
||||||
if (!url) {
|
if (!url) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "Image cannot be found", "imageNotFound");
|
throw new HttpError(HttpStatus.NOT_FOUND, "Image cannot be found", "imageNotFound");
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return req.res?.redirect(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue