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))); 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}") @Put("bank-qr/{bankId}")
@Security("keycloak") @Security("keycloak")
async putBankImage( async putBankImage(
@ -678,6 +689,11 @@ export class BranchFileController extends Controller {
return req.res?.redirect(await getFile(fileLocation.branch.line(branchId))); 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") @Put("line-image")
@Security("keycloak") @Security("keycloak")
async putLineImage(@Request() req: RequestWithUser, @Path() branchId: string) { 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)); 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}") @Put("attachment/{name}")
@Security("keycloak") @Security("keycloak")
async putAttachment( async putAttachment(

View file

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