@eggjs/multipart 5.0.0-beta.19 → 5.0.0-beta.21

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