mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
feat: wip import resources
This commit is contained in:
20
packages/server/src/api/controllers/Import/_utils.ts
Normal file
20
packages/server/src/api/controllers/Import/_utils.ts
Normal 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,
|
||||
});
|
||||
Reference in New Issue
Block a user