From 1f54d5d1dfd24803c1bda653737ea850f4d25fb0 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Mon, 17 Jun 2024 17:32:44 +0700 Subject: [PATCH] feat: image endpoint --- src/controllers/product/product-controller.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/product/product-controller.ts b/src/controllers/product/product-controller.ts index d9b035b..6bb2aeb 100644 --- a/src/controllers/product/product-controller.ts +++ b/src/controllers/product/product-controller.ts @@ -125,11 +125,12 @@ export class ProductController extends Controller { @Get("{productId}/image") async getProductImageById(@Request() req: RequestWithUser, @Path() productId: string) { const url = await presignedGetObjectIfExist(MINIO_BUCKET, imageLocation(productId), 60 * 60); + if (!url) { throw new HttpError(HttpStatus.NOT_FOUND, "Image cannot be found", "imageNotFound"); } - return; + return req.res?.redirect(url); } @Post()