diff --git a/src/controllers/05-quotation-payment-controller.ts b/src/controllers/05-quotation-payment-controller.ts index 95294aa..72843f9 100644 --- a/src/controllers/05-quotation-payment-controller.ts +++ b/src/controllers/05-quotation-payment-controller.ts @@ -1,11 +1,31 @@ -import { Body, Controller, Delete, Get, Path, Post, Put, Query, Request, Route, Tags } from "tsoa"; +import { + Body, + Controller, + Delete, + Get, + Head, + Path, + Post, + Put, + Query, + Request, + Route, + Tags, +} from "tsoa"; import express from "express"; import { PaymentStatus } from "@prisma/client"; import prisma from "../db"; import { notFoundError } from "../utils/error"; import HttpError from "../interfaces/http-error"; import HttpStatus from "../interfaces/http-status"; -import { deleteFile, fileLocation, getFile, listFile, setFile } from "../utils/minio"; +import { + deleteFile, + fileLocation, + getFile, + getFilePresigned, + listFile, + setFile, +} from "../utils/minio"; import { RequestWithUser } from "../interfaces/user"; @Tags("Quotation") @@ -83,6 +103,18 @@ export class QuotationPayment extends Controller { return await listFile(fileLocation.quotation.payment(quotationId, paymentId)); } + @Head("{paymentId}/attachment/{name}") + async headPaymentFile( + @Request() req: express.Request, + @Path() quotationId: string, + @Path() paymentId: string, + @Path() name: string, + ) { + return req.res?.redirect( + await getFilePresigned("head", fileLocation.quotation.payment(quotationId, paymentId, name)), + ); + } + @Get("{paymentId}/attachment/{name}") async getPaymentFile( @Request() req: express.Request,