feat: add head method

This commit is contained in:
Methapon Metanipat 2024-10-21 17:55:03 +07:00
parent 127db88056
commit 60a151a075

View file

@ -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,