@armi-wave/common 1.23.7 → 1.23.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/utils/multerConfig.js +12 -11
- package/package.json +1 -1
|
@@ -7,18 +7,19 @@ exports.upload = void 0;
|
|
|
7
7
|
const multer_1 = __importDefault(require("multer"));
|
|
8
8
|
// Use memory storage to avoid saving files locally
|
|
9
9
|
const storage = multer_1.default.memoryStorage();
|
|
10
|
-
//
|
|
10
|
+
// File filter function with proper TypeScript typing
|
|
11
|
+
const fileFilter = (req, file, cb) => {
|
|
12
|
+
if (file.mimetype.startsWith('image/')) {
|
|
13
|
+
cb(null, true); // Accept only image files
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
cb(new Error('Invalid file type. Only images are allowed.'));
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
// Set up multer with memory storage and proper TypeScript typing
|
|
11
20
|
const upload = (0, multer_1.default)({
|
|
12
|
-
storage
|
|
21
|
+
storage,
|
|
13
22
|
limits: { fileSize: 10 * 1024 * 1024 }, // Max file size: 10MB
|
|
14
|
-
fileFilter
|
|
15
|
-
if (file.mimetype.startsWith('image/')) {
|
|
16
|
-
// Accept only image files
|
|
17
|
-
cb(null, true);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
cb(new Error('Invalid file type. Only images are allowed.'));
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
+
fileFilter,
|
|
23
24
|
});
|
|
24
25
|
exports.upload = upload;
|