@midwayjs/upload 3.3.11 → 3.4.0-beta.2
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/README.md +2 -0
- package/dist/config/config.default.js +1 -0
- package/dist/interface.d.ts +1 -0
- package/dist/middleware.js +7 -1
- package/dist/parse.d.ts +2 -2
- package/dist/parse.js +7 -2
- package/package.json +10 -10
package/README.md
CHANGED
package/dist/interface.d.ts
CHANGED
package/dist/middleware.js
CHANGED
|
@@ -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
|
-
|
|
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
|
+
"version": "3.4.0-beta.2",
|
|
4
4
|
"description": "Midway Component for upload",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"raw-body": "2.5.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@midwayjs/core": "^3.
|
|
29
|
-
"@midwayjs/decorator": "^3.
|
|
30
|
-
"@midwayjs/express": "^3.
|
|
31
|
-
"@midwayjs/faas": "^3.
|
|
32
|
-
"@midwayjs/koa": "^3.
|
|
33
|
-
"@midwayjs/mock": "^3.
|
|
34
|
-
"@midwayjs/serverless-app": "^3.
|
|
35
|
-
"@midwayjs/web": "^3.
|
|
28
|
+
"@midwayjs/core": "^3.4.0-beta.2",
|
|
29
|
+
"@midwayjs/decorator": "^3.4.0-beta.2",
|
|
30
|
+
"@midwayjs/express": "^3.4.0-beta.2",
|
|
31
|
+
"@midwayjs/faas": "^3.4.0-beta.2",
|
|
32
|
+
"@midwayjs/koa": "^3.4.0-beta.2",
|
|
33
|
+
"@midwayjs/mock": "^3.4.0-beta.2",
|
|
34
|
+
"@midwayjs/serverless-app": "^3.4.0-beta.2",
|
|
35
|
+
"@midwayjs/web": "^3.4.0-beta.2"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "a61721d3946b30fd4cac183265edcd99b31ac72b"
|
|
38
38
|
}
|