@eggjs/multipart 5.0.0-beta.34 → 5.0.0-beta.36
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/app/extend/context.d.ts +97 -93
- package/dist/app/extend/context.js +193 -270
- package/dist/app/middleware/multipart.d.ts +6 -3
- package/dist/app/middleware/multipart.js +14 -17
- package/dist/app/schedule/clean_tmpdir.d.ts +5 -2
- package/dist/app/schedule/clean_tmpdir.js +54 -51
- package/dist/app.d.ts +9 -5
- package/dist/app.js +20 -17
- package/dist/config/config.default.d.ts +87 -84
- package/dist/config/config.default.js +27 -25
- package/dist/index.d.ts +20 -16
- package/dist/index.js +24 -21
- package/dist/lib/LimitError.d.ts +7 -4
- package/dist/lib/LimitError.js +15 -12
- package/dist/lib/MultipartFileTooLargeError.d.ts +8 -5
- package/dist/lib/MultipartFileTooLargeError.js +17 -14
- package/dist/lib/utils.d.ts +8 -4
- package/dist/lib/utils.js +68 -88
- package/dist/types.d.ts +24 -22
- package/dist/types.js +1 -2
- package/package.json +25 -32
|
@@ -1,97 +1,101 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { Context } from "egg";
|
|
2
|
+
import { Readable } from "node:stream";
|
|
3
|
+
|
|
4
|
+
//#region src/app/extend/context.d.ts
|
|
5
|
+
interface EggFile {
|
|
6
|
+
field: string;
|
|
7
|
+
filename: string;
|
|
8
|
+
encoding: string;
|
|
9
|
+
mime: string;
|
|
10
|
+
filepath: string;
|
|
9
11
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
interface MultipartFileStream extends Readable {
|
|
13
|
+
fields: Record<string, any>;
|
|
14
|
+
filename: string;
|
|
15
|
+
fieldname: string;
|
|
16
|
+
mime: string;
|
|
17
|
+
mimeType: string;
|
|
18
|
+
transferEncoding: string;
|
|
19
|
+
encoding: string;
|
|
20
|
+
truncated: boolean;
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
22
|
+
interface MultipartOptions {
|
|
23
|
+
autoFields?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* required file submit, default is true
|
|
26
|
+
*/
|
|
27
|
+
requireFile?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* default charset encoding
|
|
30
|
+
*/
|
|
31
|
+
defaultCharset?: string;
|
|
32
|
+
/**
|
|
33
|
+
* compatible with defaultCharset
|
|
34
|
+
* @deprecated use `defaultCharset` instead
|
|
35
|
+
*/
|
|
36
|
+
defCharset?: string;
|
|
37
|
+
defaultParamCharset?: string;
|
|
38
|
+
/**
|
|
39
|
+
* compatible with defaultParamCharset
|
|
40
|
+
* @deprecated use `defaultParamCharset` instead
|
|
41
|
+
*/
|
|
42
|
+
defParamCharset?: string;
|
|
43
|
+
limits?: {
|
|
44
|
+
fieldNameSize?: number;
|
|
45
|
+
fieldSize?: number;
|
|
46
|
+
fields?: number;
|
|
47
|
+
fileSize?: number;
|
|
48
|
+
files?: number;
|
|
49
|
+
parts?: number;
|
|
50
|
+
headerPairs?: number;
|
|
51
|
+
};
|
|
52
|
+
checkFile?(fieldname: string, file: any, filename: string, encoding: string, mimetype: string): void | Error;
|
|
51
53
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
54
|
+
declare class MultipartContext extends Context {
|
|
55
|
+
/**
|
|
56
|
+
* create multipart.parts instance, to get separated files.
|
|
57
|
+
* @function Context#multipart
|
|
58
|
+
* @param {Object} [options] - override default multipart configurations
|
|
59
|
+
* - {Boolean} options.autoFields
|
|
60
|
+
* - {String} options.defaultCharset
|
|
61
|
+
* - {String} options.defaultParamCharset
|
|
62
|
+
* - {Object} options.limits
|
|
63
|
+
* - {Function} options.checkFile
|
|
64
|
+
* @return {Yieldable | AsyncIterable<Yieldable>} parts
|
|
65
|
+
*/
|
|
66
|
+
multipart(options?: MultipartOptions): AsyncIterable<MultipartFileStream>;
|
|
67
|
+
/**
|
|
68
|
+
* save request multipart data and files to `ctx.request`
|
|
69
|
+
* @function Context#saveRequestFiles
|
|
70
|
+
* @param {Object} options - { limits, checkFile, ... }
|
|
71
|
+
*/
|
|
72
|
+
saveRequestFiles(options?: MultipartOptions): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* get upload file stream
|
|
75
|
+
* @example
|
|
76
|
+
* ```js
|
|
77
|
+
* const stream = await ctx.getFileStream();
|
|
78
|
+
* // get other fields
|
|
79
|
+
* console.log(stream.fields);
|
|
80
|
+
* ```
|
|
81
|
+
* @function Context#getFileStream
|
|
82
|
+
* @param {Object} options
|
|
83
|
+
* - {Boolean} options.requireFile - required file submit, default is true
|
|
84
|
+
* - {String} options.defaultCharset
|
|
85
|
+
* - {String} options.defaultParamCharset
|
|
86
|
+
* - {Object} options.limits
|
|
87
|
+
* - {Function} options.checkFile
|
|
88
|
+
* @return {ReadStream} stream
|
|
89
|
+
* @since 1.0.0
|
|
90
|
+
* @deprecated Not safe enough, use `ctx.multipart()` instead
|
|
91
|
+
*/
|
|
92
|
+
getFileStream(options?: MultipartOptions): Promise<MultipartFileStream>;
|
|
93
|
+
/**
|
|
94
|
+
* clean up request tmp files helper
|
|
95
|
+
* @function Context#cleanupRequestFiles
|
|
96
|
+
* @param {Array<String>} [files] - file paths need to cleanup, default is `ctx.request.files`.
|
|
97
|
+
*/
|
|
98
|
+
cleanupRequestFiles(files?: EggFile[]): Promise<void>;
|
|
97
99
|
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { EggFile, MultipartFileStream, MultipartOptions, MultipartContext as default };
|