feat(customer-image): add head endpoint

This commit is contained in:
Methapon Metanipat 2024-10-22 11:02:10 +07:00
parent 21e5467f55
commit 09dbac1aa2

View file

@ -4,6 +4,7 @@ import {
Controller,
Delete,
Get,
Head,
Path,
Post,
Put,
@ -24,7 +25,15 @@ import {
createPermCondition,
} from "../services/permission";
import { filterStatus } from "../services/prisma";
import { deleteFile, deleteFolder, fileLocation, getFile, listFile, setFile } from "../utils/minio";
import {
deleteFile,
deleteFolder,
fileLocation,
getFile,
getPresigned,
listFile,
setFile,
} from "../utils/minio";
import { isUsedError, notFoundError, relationError } from "../utils/error";
import { connectOrNot } from "../utils/relation";
@ -488,6 +497,17 @@ export class CustomerImageController extends Controller {
);
}
@Head("{name}")
async headImage(
@Request() req: RequestWithUser,
@Path() customerId: string,
@Path() name: string,
) {
return req.res?.redirect(
await getPresigned("head", fileLocation.customer.img(customerId, name), 12 * 60 * 60),
);
}
@Put("{name}")
@Security("keycloak")
async putImage(