refactor: upload now return presigned url instead of redirect

This will prevent from payload upload to API Server first and then
upload to MinIO which cause upload to be happens twice.
This commit is contained in:
Methapon Metanipat 2024-10-24 09:56:37 +07:00
parent ddc5a9a037
commit d5ab07bacb
4 changed files with 4 additions and 6 deletions

View file

@ -738,7 +738,7 @@ export class BranchFileController extends Controller {
@Path() name: string,
) {
await this.checkPermission(req.user, branchId);
return req.res?.redirect(await setFile(fileLocation.branch.attachment(branchId, name)));
return await setFile(fileLocation.branch.attachment(branchId, name));
}
@Delete("attachment/{name}")

View file

@ -581,7 +581,7 @@ export class CustomerBranchFileController extends Controller {
@Path() name: string,
) {
await this.checkPermission(req.user, branchId);
return req.res?.redirect(await setFile(fileLocation.customerBranch.attachment(branchId, name)));
return await setFile(fileLocation.customerBranch.attachment(branchId, name));
}
@Delete("attachment/{name}")

View file

@ -663,7 +663,7 @@ export class EmployeeFileController extends Controller {
@Path() name: string,
) {
await this.checkPermission(req.user, employeeId);
return req.res?.redirect(await setFile(fileLocation.employee.attachment(employeeId, name)));
return await setFile(fileLocation.employee.attachment(employeeId, name));
}
@Delete("attachment/{name}")

View file

@ -141,9 +141,7 @@ export class QuotationPayment extends Controller {
);
}
return req.res?.redirect(
await setFile(fileLocation.quotation.payment(quotationId, paymentId, name)),
);
return await setFile(fileLocation.quotation.payment(quotationId, paymentId, name));
}
@Delete("{paymentId}/attachment/{name}")