fix issue

This commit is contained in:
Marshal
2026-07-16 00:33:31 +00:00
parent 234a74e812
commit 41fe04652f
51 changed files with 1895 additions and 206 deletions

View File

@@ -1,4 +1,5 @@
import {
BadRequestException,
Controller,
Get,
Post,
@@ -72,7 +73,30 @@ export class DriversController {
@Post(':id/documents')
@BookingStaff(FREIGHT_PERMS.drivers.update)
@ApiConsumes('multipart/form-data')
@UseInterceptors(AnyFilesInterceptor())
// Bound the upload: 10MB/file, max 20 files, images + PDF only. Without limits
// AnyFilesInterceptor buffers arbitrarily large / arbitrary-type payloads.
@UseInterceptors(
AnyFilesInterceptor({
limits: { fileSize: 10 * 1024 * 1024, files: 20 },
fileFilter: (_req, file, cb) => {
const allowed = [
'image/jpeg',
'image/png',
'image/webp',
'image/gif',
'application/pdf',
];
if (allowed.includes(file.mimetype)) {
cb(null, true);
} else {
cb(
new BadRequestException(`Unsupported file type: ${file.mimetype}`),
false,
);
}
},
}),
)
@ApiOperation({ summary: 'Upload driver documents (code driver_docs)' })
uploadDocuments(
@Param('id', ParseUUIDPipe) id: string,