@kiyasov/platform-hono 1.4.2 → 1.4.3
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/dist/cjs/src/multer/multipart/handlers/multiple-files.js +16 -10
- package/dist/cjs/src/multer/multipart/handlers/multiple-files.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/multer/multipart/handlers/multiple-files.js +16 -10
- package/dist/esm/src/multer/multipart/handlers/multiple-files.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/multer/multipart/handlers/multiple-files.ts +28 -14
package/package.json
CHANGED
|
@@ -24,27 +24,41 @@ export const handleMultipartMultipleFiles = async (
|
|
|
24
24
|
|
|
25
25
|
try {
|
|
26
26
|
for await (const [partFieldName, part] of Object.entries(parts)) {
|
|
27
|
-
if (!(part instanceof File)) {
|
|
27
|
+
if (!(part instanceof File || Array.isArray(part))) {
|
|
28
28
|
body[partFieldName] = part;
|
|
29
29
|
continue;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
throw new BadRequestException(
|
|
34
|
-
`Field ${partFieldName} doesn't accept files`,
|
|
35
|
-
);
|
|
36
|
-
}
|
|
32
|
+
const partArray = Array.isArray(part) ? part : [part];
|
|
37
33
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
for (const singlePart of partArray) {
|
|
35
|
+
if (!(singlePart instanceof File)) {
|
|
36
|
+
throw new BadRequestException(
|
|
37
|
+
`Field ${partFieldName} contains invalid file data`,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
43
40
|
|
|
44
|
-
|
|
41
|
+
if (partFieldName !== fieldname) {
|
|
42
|
+
throw new BadRequestException(
|
|
43
|
+
`Field ${partFieldName} doesn't accept files`,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (files.length >= maxCount) {
|
|
48
|
+
throw new BadRequestException(
|
|
49
|
+
`Field ${partFieldName} accepts max ${maxCount} files`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const file = await options.storage!.handleFile(
|
|
54
|
+
singlePart,
|
|
55
|
+
req,
|
|
56
|
+
partFieldName,
|
|
57
|
+
);
|
|
45
58
|
|
|
46
|
-
|
|
47
|
-
|
|
59
|
+
if (await filterUpload(options, req, file)) {
|
|
60
|
+
files.push(file);
|
|
61
|
+
}
|
|
48
62
|
}
|
|
49
63
|
}
|
|
50
64
|
} catch (error) {
|