feat: image endpoint

This commit is contained in:
Methapon2001 2024-06-17 17:32:44 +07:00
parent e0184631da
commit 1f54d5d1df

View file

@ -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()