feat: wip import resources

This commit is contained in:
Ahmed Bouhuolia
2024-03-15 00:18:41 +02:00
parent 084d9d3d10
commit ab4c0ab7a7
14 changed files with 96 additions and 125 deletions

View File

@@ -0,0 +1,20 @@
import Multer from 'multer';
import { ServiceError } from '@/exceptions';
export function allowSheetExtensions(req, file, cb) {
if (
file.mimetype !== 'text/csv' &&
file.mimetype !== 'application/vnd.ms-excel'
) {
cb(new ServiceError('IMPORTED_FILE_EXTENSION_INVALID'));
return;
}
cb(null, true);
}
export const uploadImportFile = Multer({
dest: './public/imports',
limits: { fileSize: 5 * 1024 * 1024 },
fileFilter: allowSheetExtensions,
});