feat: add head to more endpoint

This commit is contained in:
Methapon Metanipat 2024-10-22 17:54:46 +07:00
parent 65c70ffec3
commit 6235186ff9
2 changed files with 37 additions and 1 deletions

View file

@ -648,6 +648,17 @@ export class BranchFileController extends Controller {
return req.res?.redirect(await getFile(fileLocation.branch.bank(branchId, bankId)));
}
@Head("bank-qr/{bankId}")
async headBankImage(
@Request() req: RequestWithUser,
@Path() branchId: string,
@Path() bankId: string,
) {
return req.res?.redirect(
await getPresigned("head", fileLocation.branch.bank(branchId, bankId)),
);
}
@Put("bank-qr/{bankId}")
@Security("keycloak")
async putBankImage(
@ -678,6 +689,11 @@ export class BranchFileController extends Controller {
return req.res?.redirect(await getFile(fileLocation.branch.line(branchId)));
}
@Head("line-image")
async headLineImage(@Request() req: RequestWithUser, @Path() branchId: string) {
return req.res?.redirect(await getPresigned("head", fileLocation.branch.line(branchId)));
}
@Put("line-image")
@Security("keycloak")
async putLineImage(@Request() req: RequestWithUser, @Path() branchId: string) {
@ -708,6 +724,12 @@ export class BranchFileController extends Controller {
return await getFile(fileLocation.branch.attachment(branchId, name));
}
@Head("attachment/{name}")
@Security("keycloak")
async headAttachment(@Path() branchId: string, @Path() name: string) {
return await getPresigned("head", fileLocation.branch.attachment(branchId, name));
}
@Put("attachment/{name}")
@Security("keycloak")
async putAttachment(

View file

@ -11,6 +11,7 @@ import {
Route,
Security,
Tags,
Head,
} from "tsoa";
import { Branch, Prisma, Status, User, UserType } from "@prisma/client";
@ -28,7 +29,15 @@ import {
removeUserRoles,
} from "../services/keycloak";
import { isSystem } from "../utils/keycloak";
import { deleteFile, deleteFolder, fileLocation, getFile, listFile, setFile } from "../utils/minio";
import {
deleteFile,
deleteFolder,
fileLocation,
getFile,
getPresigned,
listFile,
setFile,
} from "../utils/minio";
import { filterStatus } from "../services/prisma";
import {
branchRelationPermInclude,
@ -706,6 +715,11 @@ export class UserProfileController extends Controller {
return req.res?.redirect(await getFile(fileLocation.user.profile(userId, name)));
}
@Head("{name}")
async headImage(@Request() req: RequestWithUser, @Path() userId: string, @Path() name: string) {
return req.res?.redirect(await getPresigned("head", fileLocation.user.profile(userId, name)));
}
@Put("{name}")
@Security("keycloak")
async putImage(@Request() req: RequestWithUser, @Path() userId: string, @Path() name: string) {