фикс багов
This commit is contained in:
@@ -135,7 +135,7 @@ export const uploadFile = multer({
|
||||
cb(null, `${uuidv4()}${ext}`);
|
||||
},
|
||||
}),
|
||||
limits: { fileSize: 50 * 1024 * 1024 },
|
||||
limits: { fileSize: 200 * 1024 * 1024 },
|
||||
fileFilter: (_req, file, cb) => {
|
||||
const ext = path.extname(file.originalname).toLowerCase();
|
||||
if (BLOCKED_EXTENSIONS.has(ext)) {
|
||||
@@ -158,15 +158,20 @@ export function encryptUploadedFile(req: Request, _res: Response, next: NextFunc
|
||||
try {
|
||||
// Single file upload (req.file)
|
||||
if (req.file) {
|
||||
encryptFileInPlace(req.file.path);
|
||||
// Don't encrypt videos and audio as they need range support and are large
|
||||
if (!req.file.mimetype.startsWith('video/') && !req.file.mimetype.startsWith('audio/')) {
|
||||
encryptFileInPlace(req.file.path);
|
||||
}
|
||||
}
|
||||
// Multiple files (req.files) — handle both array and field-keyed forms
|
||||
if (req.files) {
|
||||
const files = Array.isArray(req.files)
|
||||
? req.files
|
||||
: Object.values(req.files).flat();
|
||||
: Object.values(req.files).flat() as Express.Multer.File[];
|
||||
for (const file of files) {
|
||||
encryptFileInPlace(file.path);
|
||||
if (!file.mimetype.startsWith('video/') && !file.mimetype.startsWith('audio/')) {
|
||||
encryptFileInPlace(file.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user