feat: branch attachment

This commit is contained in:
Methapon Metanipat 2024-09-12 13:29:48 +07:00
parent 155962b996
commit b9a616b9a9
2 changed files with 36 additions and 0 deletions

View file

@ -674,4 +674,39 @@ export class BranchFileController extends Controller {
await this.checkPermission(req.user, branchId);
return await deleteFile(fileLocation.branch.line(branchId));
}
@Get("attachment")
@Security("keycloak")
async listAttachment(@Request() req: RequestWithUser, @Path() branchId: string) {
await this.checkPermission(req.user, branchId);
return await listFile(fileLocation.branch.attachment(branchId));
}
@Get("attachment/{name}")
@Security("keycloak")
async getAttachment(@Path() branchId: string, @Path() name: string) {
return await getFile(fileLocation.branch.attachment(branchId, name));
}
@Put("attachment/{name}")
@Security("keycloak")
async putAttachment(
@Request() req: RequestWithUser,
@Path() branchId: string,
@Path() name: string,
) {
await this.checkPermission(req.user, branchId);
return req.res?.redirect(await setFile(fileLocation.branch.attachment(branchId, name)));
}
@Delete("attachment/{name}")
@Security("keycloak")
async delAttachment(
@Request() req: RequestWithUser,
@Path() branchId: string,
@Path() name: string,
) {
await this.checkPermission(req.user, branchId);
return await deleteFile(fileLocation.branch.attachment(branchId, name));
}
}