@midwayjs/upload 3.3.9 → 3.4.0-beta.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,362 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [3.3.11](https://github.com/midwayjs/midway/compare/v3.3.10...v3.3.11) (2022-05-27)
7
+
8
+ **Note:** Version bump only for package @midwayjs/upload
9
+
10
+
11
+
12
+
13
+
14
+ ## [3.3.9](https://github.com/midwayjs/midway/compare/v3.3.8...v3.3.9) (2022-05-25)
15
+
16
+ **Note:** Version bump only for package @midwayjs/upload
17
+
18
+
19
+
20
+
21
+
22
+ ## [3.3.6](https://github.com/midwayjs/midway/compare/v3.3.5...v3.3.6) (2022-05-11)
23
+
24
+ **Note:** Version bump only for package @midwayjs/upload
25
+
26
+
27
+
28
+
29
+
30
+ ## [3.3.5](https://github.com/midwayjs/midway/compare/v3.3.4...v3.3.5) (2022-04-27)
31
+
32
+ **Note:** Version bump only for package @midwayjs/upload
33
+
34
+
35
+
36
+
37
+
38
+ ## [3.3.4](https://github.com/midwayjs/midway/compare/v3.3.3...v3.3.4) (2022-04-21)
39
+
40
+ **Note:** Version bump only for package @midwayjs/upload
41
+
42
+
43
+
44
+
45
+
46
+ ## [3.3.3](https://github.com/midwayjs/midway/compare/v3.3.2...v3.3.3) (2022-04-14)
47
+
48
+ **Note:** Version bump only for package @midwayjs/upload
49
+
50
+
51
+
52
+
53
+
54
+ ## [3.3.2](https://github.com/midwayjs/midway/compare/v3.3.1...v3.3.2) (2022-04-13)
55
+
56
+ **Note:** Version bump only for package @midwayjs/upload
57
+
58
+
59
+
60
+
61
+
62
+ ## [3.3.1](https://github.com/midwayjs/midway/compare/v3.3.0...v3.3.1) (2022-04-11)
63
+
64
+ **Note:** Version bump only for package @midwayjs/upload
65
+
66
+
67
+
68
+
69
+
70
+ # [3.3.0](https://github.com/midwayjs/midway/compare/v3.2.2...v3.3.0) (2022-04-07)
71
+
72
+ **Note:** Version bump only for package @midwayjs/upload
73
+
74
+
75
+
76
+
77
+
78
+ ## [3.2.2](https://github.com/midwayjs/midway/compare/v3.2.1...v3.2.2) (2022-03-30)
79
+
80
+ **Note:** Version bump only for package @midwayjs/upload
81
+
82
+
83
+
84
+
85
+
86
+ ## [3.2.1](https://github.com/midwayjs/midway/compare/v3.2.0...v3.2.1) (2022-03-27)
87
+
88
+
89
+ ### Bug Fixes
90
+
91
+ * swagger ui replace json path ([#1860](https://github.com/midwayjs/midway/issues/1860)) ([0f3728d](https://github.com/midwayjs/midway/commit/0f3728daccba12923f23f5b498c7dda13ced36d7))
92
+
93
+
94
+
95
+
96
+
97
+ # [3.2.0](https://github.com/midwayjs/midway/compare/v3.1.6...v3.2.0) (2022-03-25)
98
+
99
+
100
+ ### Bug Fixes
101
+
102
+ * throw error when cluster exec ([#1848](https://github.com/midwayjs/midway/issues/1848)) ([bf0e209](https://github.com/midwayjs/midway/commit/bf0e209ec724ab41b5bc9b43b08d7c44d3b77e3b))
103
+ * upload file support more http method ([#1846](https://github.com/midwayjs/midway/issues/1846)) ([7587898](https://github.com/midwayjs/midway/commit/75878986ba69c41f58de1165d07938f094ce9ab2))
104
+
105
+
106
+
107
+
108
+
109
+ ## [3.1.6](https://github.com/midwayjs/midway/compare/v3.1.5...v3.1.6) (2022-03-21)
110
+
111
+ **Note:** Version bump only for package @midwayjs/upload
112
+
113
+
114
+
115
+
116
+
117
+ ## [3.1.5](https://github.com/midwayjs/midway/compare/v3.1.4...v3.1.5) (2022-03-18)
118
+
119
+ **Note:** Version bump only for package @midwayjs/upload
120
+
121
+
122
+
123
+
124
+
125
+ ## [3.1.4](https://github.com/midwayjs/midway/compare/v3.1.3...v3.1.4) (2022-03-16)
126
+
127
+ **Note:** Version bump only for package @midwayjs/upload
128
+
129
+
130
+
131
+
132
+
133
+ ## [3.1.3](https://github.com/midwayjs/midway/compare/v3.1.2...v3.1.3) (2022-03-15)
134
+
135
+ **Note:** Version bump only for package @midwayjs/upload
136
+
137
+
138
+
139
+
140
+
141
+ ## [3.1.2](https://github.com/midwayjs/midway/compare/v3.1.1...v3.1.2) (2022-03-15)
142
+
143
+ **Note:** Version bump only for package @midwayjs/upload
144
+
145
+
146
+
147
+
148
+
149
+ ## [3.1.1](https://github.com/midwayjs/midway/compare/v3.1.0...v3.1.1) (2022-03-09)
150
+
151
+ **Note:** Version bump only for package @midwayjs/upload
152
+
153
+
154
+
155
+
156
+
157
+ # [3.1.0](https://github.com/midwayjs/midway/compare/v3.0.13...v3.1.0) (2022-03-07)
158
+
159
+ **Note:** Version bump only for package @midwayjs/upload
160
+
161
+
162
+
163
+
164
+
165
+ ## [3.0.13](https://github.com/midwayjs/midway/compare/v3.0.12...v3.0.13) (2022-03-01)
166
+
167
+
168
+ ### Bug Fixes
169
+
170
+ * **deps:** update dependency raw-body to v2.5.1 ([#1754](https://github.com/midwayjs/midway/issues/1754)) ([6d9d819](https://github.com/midwayjs/midway/commit/6d9d819a3628ac8ecf91e75120a73f0533ba4bc9))
171
+
172
+
173
+
174
+
175
+
176
+ ## [3.0.11](https://github.com/midwayjs/midway/compare/v3.0.10...v3.0.11) (2022-02-25)
177
+
178
+ **Note:** Version bump only for package @midwayjs/upload
179
+
180
+
181
+
182
+
183
+
184
+ ## [3.0.10](https://github.com/midwayjs/midway/compare/v3.0.9...v3.0.10) (2022-02-24)
185
+
186
+
187
+ ### Bug Fixes
188
+
189
+ * **deps:** update dependency raw-body to v2.5.0 ([#1731](https://github.com/midwayjs/midway/issues/1731)) ([6caec96](https://github.com/midwayjs/midway/commit/6caec96b976b9dce1a8cda4d3f809efd346ceaf5))
190
+
191
+
192
+
193
+
194
+
195
+ ## [3.0.9](https://github.com/midwayjs/midway/compare/v3.0.8...v3.0.9) (2022-02-21)
196
+
197
+ **Note:** Version bump only for package @midwayjs/upload
198
+
199
+
200
+
201
+
202
+
203
+ ## [3.0.8](https://github.com/midwayjs/midway/compare/v3.0.7...v3.0.8) (2022-02-19)
204
+
205
+ **Note:** Version bump only for package @midwayjs/upload
206
+
207
+
208
+
209
+
210
+
211
+ ## [3.0.7](https://github.com/midwayjs/midway/compare/v3.0.6...v3.0.7) (2022-02-17)
212
+
213
+
214
+ ### Bug Fixes
215
+
216
+ * **deps:** update dependency raw-body to v2.4.3 ([#1705](https://github.com/midwayjs/midway/issues/1705)) ([d4a6b8c](https://github.com/midwayjs/midway/commit/d4a6b8c0a17d5187ac21afd72e8dbf86424fb14f))
217
+
218
+
219
+
220
+
221
+
222
+ ## [3.0.6](https://github.com/midwayjs/midway/compare/v3.0.5...v3.0.6) (2022-02-13)
223
+
224
+ **Note:** Version bump only for package @midwayjs/upload
225
+
226
+
227
+
228
+
229
+
230
+ ## [3.0.5](https://github.com/midwayjs/midway/compare/v3.0.4...v3.0.5) (2022-02-10)
231
+
232
+ **Note:** Version bump only for package @midwayjs/upload
233
+
234
+
235
+
236
+
237
+
238
+ ## [3.0.4](https://github.com/midwayjs/midway/compare/v3.0.3...v3.0.4) (2022-02-09)
239
+
240
+
241
+ ### Bug Fixes
242
+
243
+ * supertest typings and createFunctionApp ([#1642](https://github.com/midwayjs/midway/issues/1642)) ([484f4f4](https://github.com/midwayjs/midway/commit/484f4f41b3b9e889d4d285f4871a0b37fa51e73f))
244
+
245
+
246
+
247
+
248
+
249
+ ## [3.0.3](https://github.com/midwayjs/midway/compare/v3.0.2...v3.0.3) (2022-01-28)
250
+
251
+ **Note:** Version bump only for package @midwayjs/upload
252
+
253
+
254
+
255
+
256
+
257
+ ## [3.0.2](https://github.com/midwayjs/midway/compare/v3.0.1...v3.0.2) (2022-01-24)
258
+
259
+
260
+ ### Bug Fixes
261
+
262
+ * singleton invoke request scope not valid ([#1622](https://github.com/midwayjs/midway/issues/1622)) ([f97c063](https://github.com/midwayjs/midway/commit/f97c0632107b47cf357d17774a4e4bb5233bba57))
263
+
264
+
265
+
266
+
267
+
268
+ ## [3.0.1](https://github.com/midwayjs/midway/compare/v3.0.0...v3.0.1) (2022-01-24)
269
+
270
+
271
+ ### Bug Fixes
272
+
273
+ * config key required ([#1615](https://github.com/midwayjs/midway/issues/1615)) ([fb2188e](https://github.com/midwayjs/midway/commit/fb2188eaf5c24ffc9972f73323773a5899825037))
274
+
275
+
276
+
277
+
278
+
279
+ # [3.0.0](https://github.com/midwayjs/midway/compare/v3.0.0-beta.17...v3.0.0) (2022-01-20)
280
+
281
+ **Note:** Version bump only for package @midwayjs/upload
282
+
283
+
284
+
285
+
286
+
287
+ # [3.0.0-beta.17](https://github.com/midwayjs/midway/compare/v3.0.0-beta.16...v3.0.0-beta.17) (2022-01-18)
288
+
289
+ **Note:** Version bump only for package @midwayjs/upload
290
+
291
+
292
+
293
+
294
+
295
+ # [3.0.0-beta.16](https://github.com/midwayjs/midway/compare/v3.0.0-beta.15...v3.0.0-beta.16) (2022-01-11)
296
+
297
+
298
+ ### Bug Fixes
299
+
300
+ * typings ([4afffe6](https://github.com/midwayjs/midway/commit/4afffe62ddfa97346863691a24065f5820bb9531))
301
+
302
+
303
+
304
+
305
+
306
+ # [3.0.0-beta.15](https://github.com/midwayjs/midway/compare/v3.0.0-beta.14...v3.0.0-beta.15) (2022-01-07)
307
+
308
+
309
+ ### Features
310
+
311
+ * cross domain component ([#1493](https://github.com/midwayjs/midway/issues/1493)) ([ca81b2f](https://github.com/midwayjs/midway/commit/ca81b2fa2824fbddc7870a971fa23274c86d05df))
312
+
313
+
314
+
315
+
316
+
317
+ # [3.0.0-beta.14](https://github.com/midwayjs/midway/compare/v3.0.0-beta.13...v3.0.0-beta.14) (2022-01-04)
318
+
319
+
320
+ ### Bug Fixes
321
+
322
+ * cos config definition & 3.x doc update ([#1515](https://github.com/midwayjs/midway/issues/1515)) ([0ac7ac5](https://github.com/midwayjs/midway/commit/0ac7ac5805b7ab8873f8792fc1712a74e3223172))
323
+ * upload support auto clean and whitelist ([#1484](https://github.com/midwayjs/midway/issues/1484)) ([7daa037](https://github.com/midwayjs/midway/commit/7daa0371f4a3e79cd4789959d8427fc5b6c91d08))
324
+
325
+
326
+
327
+
328
+
329
+ # [3.0.0-beta.13](https://github.com/midwayjs/midway/compare/v3.0.0-beta.12...v3.0.0-beta.13) (2021-12-30)
330
+
331
+ **Note:** Version bump only for package @midwayjs/upload
332
+
333
+
334
+
335
+
336
+
337
+ # [3.0.0-beta.12](https://github.com/midwayjs/midway/compare/v3.0.0-beta.11...v3.0.0-beta.12) (2021-12-28)
338
+
339
+
340
+ ### Features
341
+
342
+ * custom error code & add @Files/@Fields ([#1438](https://github.com/midwayjs/midway/issues/1438)) ([b0032af](https://github.com/midwayjs/midway/commit/b0032afd2fa9ea0416fe69f4bd0c1a58bea5314e))
343
+ * support throw err status ([#1440](https://github.com/midwayjs/midway/issues/1440)) ([7b98110](https://github.com/midwayjs/midway/commit/7b98110d65c5287a8fcb3eb5356dea2d7a32cee9))
344
+
345
+
346
+
347
+
348
+
349
+ # [3.0.0-beta.11](https://github.com/midwayjs/midway/compare/v3.0.0-beta.10...v3.0.0-beta.11) (2021-12-21)
350
+
351
+ **Note:** Version bump only for package @midwayjs/upload
352
+
353
+
354
+
355
+
356
+
357
+ # [3.0.0-beta.10](https://github.com/midwayjs/midway/compare/v3.0.0-beta.9...v3.0.0-beta.10) (2021-12-20)
358
+
359
+
360
+ ### Features
361
+
362
+ * 3.x upload ([#1422](https://github.com/midwayjs/midway/issues/1422)) ([cbd8e33](https://github.com/midwayjs/midway/commit/cbd8e334a918222f526552859401f0cf222737b6))
package/README.md CHANGED
@@ -70,5 +70,7 @@ export const upload = {
70
70
  tmpdir: join(tmpdir(), 'midway-upload-files'),
71
71
  // cleanTimeout: number,上传的文件在临时目录中多久之后自动删除,默认为 5 分钟
72
72
  cleanTimeout: 5 * 60 * 1000,
73
+ // base64: boolean,设置原始body是否是base64格式,默认为false,一般用于腾讯云的兼容
74
+ base64: false,
73
75
  }
74
76
  ```
@@ -10,5 +10,6 @@ exports.upload = {
10
10
  whitelist: constants_1.uploadWhiteList,
11
11
  tmpdir: (0, path_1.join)((0, os_1.tmpdir)(), 'midway-upload-files'),
12
12
  cleanTimeout: 5 * 60 * 1000,
13
+ base64: false,
13
14
  };
14
15
  //# sourceMappingURL=config.default.js.map
@@ -7,6 +7,7 @@ export interface UploadOptions {
7
7
  whitelist?: string[];
8
8
  tmpdir?: string;
9
9
  cleanTimeout?: number;
10
+ base64?: boolean;
10
11
  }
11
12
  export interface UploadFileInfo<T> {
12
13
  filename: string;
@@ -34,6 +34,7 @@ let UploadMiddleware = class UploadMiddleware {
34
34
  }
35
35
  }
36
36
  async execUpload(ctx, req, res, next, isExpress) {
37
+ var _a;
37
38
  const { mode, tmpdir, fileSize } = this.upload;
38
39
  const boundary = this.getUploadBoundary(req);
39
40
  if (!boundary) {
@@ -76,10 +77,15 @@ let UploadMiddleware = class UploadMiddleware {
76
77
  limit: fileSize,
77
78
  });
78
79
  }
80
+ else if (((_a = req === null || req === void 0 ? void 0 : req.originEvent) === null || _a === void 0 ? void 0 : _a.body) &&
81
+ (typeof req.originEvent.body === 'string' ||
82
+ Buffer.isBuffer(req.originEvent.body))) {
83
+ body = req.originEvent.body;
84
+ }
79
85
  else {
80
86
  body = req.body;
81
87
  }
82
- const data = await (0, parse_1.parseMultipart)(body, boundary);
88
+ const data = await (0, parse_1.parseMultipart)(body, boundary, this.upload);
83
89
  if (!data) {
84
90
  return next();
85
91
  }
package/dist/parse.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { Readable } from 'stream';
3
- import { UploadFileInfo } from './interface';
4
- export declare const parseMultipart: (body: any, boundary: string) => Promise<{
3
+ import { UploadFileInfo, UploadOptions } from './interface';
4
+ export declare const parseMultipart: (body: any, boundary: string, uploadConfig: UploadOptions) => Promise<{
5
5
  files: any[];
6
6
  fields: {};
7
7
  }>;
package/dist/parse.js CHANGED
@@ -3,9 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseHead = exports.bufferSplit = exports.bufferIndexOf = exports.parseFromReadableStream = exports.parseMultipart = void 0;
4
4
  const stream_1 = require("stream");
5
5
  const headSeparator = Buffer.from('\r\n\r\n');
6
- const parseMultipart = async (body, boundary) => {
6
+ const parseMultipart = async (body, boundary, uploadConfig) => {
7
7
  if (typeof body === 'string') {
8
- body = Buffer.from(body);
8
+ if (uploadConfig.base64) {
9
+ body = Buffer.from(body, 'base64');
10
+ }
11
+ else {
12
+ body = Buffer.from(body);
13
+ }
9
14
  }
10
15
  const bufferSeparator = Buffer.from('\r\n--' + boundary);
11
16
  const fields = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/upload",
3
- "version": "3.3.9",
3
+ "version": "3.4.0-beta.1",
4
4
  "description": "Midway Component for upload",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -25,14 +25,13 @@
25
25
  "raw-body": "2.5.1"
26
26
  },
27
27
  "devDependencies": {
28
- "@midwayjs/core": "^3.3.5",
29
- "@midwayjs/decorator": "^3.3.4",
30
- "@midwayjs/express": "^3.3.6",
31
- "@midwayjs/faas": "^3.3.5",
32
- "@midwayjs/koa": "^3.3.6",
33
- "@midwayjs/mock": "^3.3.5",
34
- "@midwayjs/serverless-app": "^3.3.9",
35
- "@midwayjs/web": "^3.3.9"
36
- },
37
- "gitHead": "6fb04e62985a6ed0adc76f74d3c17350f37f9fe7"
28
+ "@midwayjs/core": "^3.4.0-beta.1",
29
+ "@midwayjs/decorator": "^3.4.0-beta.1",
30
+ "@midwayjs/express": "^3.4.0-beta.1",
31
+ "@midwayjs/faas": "^3.4.0-beta.1",
32
+ "@midwayjs/koa": "^3.4.0-beta.1",
33
+ "@midwayjs/mock": "^3.4.0-beta.1",
34
+ "@midwayjs/serverless-app": "^3.4.0-beta.1",
35
+ "@midwayjs/web": "^3.4.0-beta.1"
36
+ }
38
37
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2013 - Now midwayjs
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.