@midwayjs/upload 4.0.0-beta.1 → 4.0.0-beta.10

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/LICENSE ADDED
@@ -0,0 +1,21 @@
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.
@@ -15,6 +15,8 @@ const DefaultConfig = require("./config/config.default");
15
15
  const middleware_1 = require("./middleware");
16
16
  const utils_1 = require("./utils");
17
17
  let UploadConfiguration = class UploadConfiguration {
18
+ applicationManager;
19
+ uploadConfig;
18
20
  async onReady() {
19
21
  const { tmpdir, cleanTimeout } = this.uploadConfig;
20
22
  if (tmpdir) {
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Readable } from 'stream';
3
2
  import { IgnoreMatcher, IMidwayContext } from '@midwayjs/core';
4
3
  export type UploadMode = 'stream' | 'file';
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { IMiddleware, ILogger, IgnoreMatcher } from '@midwayjs/core';
4
2
  import { UploadOptions } from '.';
5
3
  export declare class UploadMiddleware implements IMiddleware<any, any> {
@@ -21,18 +21,20 @@ const file_type_1 = require("file-type");
21
21
  const utils_1 = require("./utils");
22
22
  const { unlink, writeFile } = fs_1.promises;
23
23
  let UploadMiddleware = class UploadMiddleware {
24
- constructor() {
25
- /**
26
- * cache global upload white list when uploadConfig.whitelist is set
27
- * @private
28
- */
29
- this.uploadWhiteListMap = new Map();
30
- /**
31
- * cache global upload mime type white list when uploadConfig.mimeTypeWhiteList is set
32
- * @private
33
- */
34
- this.uploadFileMimeTypeMap = new Map();
35
- }
24
+ uploadConfig;
25
+ logger;
26
+ /**
27
+ * cache global upload white list when uploadConfig.whitelist is set
28
+ * @private
29
+ */
30
+ uploadWhiteListMap = new Map();
31
+ /**
32
+ * cache global upload mime type white list when uploadConfig.mimeTypeWhiteList is set
33
+ * @private
34
+ */
35
+ uploadFileMimeTypeMap = new Map();
36
+ match;
37
+ ignore;
36
38
  async init() {
37
39
  if (this.uploadConfig.match) {
38
40
  this.match = [].concat(this.uploadConfig.match || []);
package/dist/parse.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
1
  import { Readable } from 'stream';
5
2
  import { UploadFileInfo, UploadOptions } from './interface';
6
3
  export declare const parseMultipart: (body: any, boundary: string, uploadConfig: UploadOptions) => Promise<{
package/dist/parse.js CHANGED
@@ -191,7 +191,9 @@ const parseHead = (headBuf) => {
191
191
  if (name === 'content-disposition') {
192
192
  const headCol = {};
193
193
  value.split(/;\s+/).forEach((kv) => {
194
- const [k, v] = kv.split('=');
194
+ const eqIndex = kv.indexOf('=');
195
+ const k = eqIndex !== -1 ? kv.substring(0, eqIndex) : kv;
196
+ const v = eqIndex !== -1 ? kv.substring(eqIndex + 1) : undefined;
195
197
  headCol[k] = v ? v.replace(/^"/, '').replace(/"$/, '') : v ?? true;
196
198
  });
197
199
  head[name] = headCol;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/upload",
3
- "version": "4.0.0-beta.1",
3
+ "version": "4.0.0-beta.10",
4
4
  "description": "Midway Component for upload",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "index.d.ts"
19
19
  ],
20
20
  "engines": {
21
- "node": ">=12"
21
+ "node": ">=20"
22
22
  },
23
23
  "license": "MIT",
24
24
  "dependencies": {
@@ -26,12 +26,12 @@
26
26
  "raw-body": "2.5.2"
27
27
  },
28
28
  "devDependencies": {
29
- "@midwayjs/core": "^4.0.0-beta.1",
30
- "@midwayjs/express": "^4.0.0-beta.1",
31
- "@midwayjs/faas": "^4.0.0-beta.1",
32
- "@midwayjs/koa": "^4.0.0-beta.1",
33
- "@midwayjs/mock": "^4.0.0-beta.1",
34
- "@midwayjs/web": "^4.0.0-beta.1"
29
+ "@midwayjs/core": "^4.0.0-beta.10",
30
+ "@midwayjs/express": "^4.0.0-beta.10",
31
+ "@midwayjs/faas": "^4.0.0-beta.10",
32
+ "@midwayjs/koa": "^4.0.0-beta.10",
33
+ "@midwayjs/mock": "^4.0.0-beta.10",
34
+ "@midwayjs/web": "^4.0.0-beta.10"
35
35
  },
36
- "gitHead": "832961ec3aff123c033197d8c00cb2bc9bad7ff8"
36
+ "gitHead": "1b1856629913703f67304155aaf611ec936a81ac"
37
37
  }