mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-14 20:00:33 +00:00
21 lines
476 B
TypeScript
21 lines
476 B
TypeScript
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,
|
|
});
|