@duvdu-v1/duvdu 1.1.223 → 1.1.224
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.
|
@@ -31,7 +31,6 @@ const globalUploadMiddleware = (folder, options) => {
|
|
|
31
31
|
fileFilter: (options === null || options === void 0 ? void 0 : options.fileFilter)
|
|
32
32
|
? options.fileFilter
|
|
33
33
|
: function fileFilter(req, file, callback) {
|
|
34
|
-
var _a;
|
|
35
34
|
if (!(options === null || options === void 0 ? void 0 : options.fileTypes)) {
|
|
36
35
|
if (!file.mimetype.startsWith('image')) {
|
|
37
36
|
return callback(new bad_request_error_1.BadRequestError({
|
|
@@ -41,7 +40,12 @@ const globalUploadMiddleware = (folder, options) => {
|
|
|
41
40
|
}
|
|
42
41
|
return callback(null, true);
|
|
43
42
|
}
|
|
44
|
-
|
|
43
|
+
const isValidType = options.fileTypes.some((type) => {
|
|
44
|
+
const [category, subtype] = type.split('/');
|
|
45
|
+
const [fileCategory, fileSubtype] = file.mimetype.split('/');
|
|
46
|
+
return category === fileCategory && (subtype === '*' || subtype === fileSubtype);
|
|
47
|
+
});
|
|
48
|
+
if (isValidType) {
|
|
45
49
|
return callback(null, true);
|
|
46
50
|
}
|
|
47
51
|
else {
|