From 53ef90115609759dc327988c02b38d9b356f71b4 Mon Sep 17 00:00:00 2001 From: Junyi Date: Sun, 1 May 2022 22:35:41 +0800 Subject: [PATCH] fix(plugin-file-manager): upgrade multer-aliyun-oss package to fix size (#352) --- packages/plugins/file-manager/package.json | 2 +- .../src/__tests__/storages/ali-oss.test.ts | 8 ++--- .../src/__tests__/storages/s3.test.ts | 5 +-- yarn.lock | 34 ++++++++----------- 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/packages/plugins/file-manager/package.json b/packages/plugins/file-manager/package.json index f0202f9e87..75594e549a 100644 --- a/packages/plugins/file-manager/package.json +++ b/packages/plugins/file-manager/package.json @@ -22,7 +22,7 @@ "mime-match": "^1.0.2", "mkdirp": "~0.5.4", "multer": "^1.4.2", - "multer-aliyun-oss": "1.1.1", + "multer-aliyun-oss": "2.1.1", "multer-s3": "^2.10.0" }, "devDependencies": { diff --git a/packages/plugins/file-manager/src/__tests__/storages/ali-oss.test.ts b/packages/plugins/file-manager/src/__tests__/storages/ali-oss.test.ts index 4f11801279..ed9a7d1f72 100644 --- a/packages/plugins/file-manager/src/__tests__/storages/ali-oss.test.ts +++ b/packages/plugins/file-manager/src/__tests__/storages/ali-oss.test.ts @@ -11,6 +11,7 @@ describe('storage:ali-oss', () => { let app: MockServer; let agent; let db: Database; + let storage; beforeEach(async () => { app = await getApp(); @@ -18,7 +19,7 @@ describe('storage:ali-oss', () => { db = app.db; const Storage = db.getCollection('storages').model; - await Storage.create({ + storage = await Storage.create({ ...aliossStorage.defaults(), name: `ali-oss_${db.getTablePrefix()}`, default: true, @@ -46,11 +47,10 @@ describe('storage:ali-oss', () => { title: 'text', extname: '.txt', path: 'test/path', - // TODO(bug): alioss will not return the size of file - // size: 13, + size: 13, mimetype: 'text/plain', meta: {}, - storage_id: 1, + storageId: storage.id, }; // 文件上传和解析是否正常 diff --git a/packages/plugins/file-manager/src/__tests__/storages/s3.test.ts b/packages/plugins/file-manager/src/__tests__/storages/s3.test.ts index d78ad00c27..76175d552b 100644 --- a/packages/plugins/file-manager/src/__tests__/storages/s3.test.ts +++ b/packages/plugins/file-manager/src/__tests__/storages/s3.test.ts @@ -11,6 +11,7 @@ describe('storage:s3', () => { let app: MockServer; let agent; let db: Database; + let storage; beforeEach(async () => { app = await getApp(); @@ -18,7 +19,7 @@ describe('storage:s3', () => { db = app.db; const Storage = db.getCollection('storages').model; - await Storage.create({ + storage = await Storage.create({ ...s3Storage.defaults(), name: `s3_${db.getTablePrefix()}`, default: true, @@ -49,7 +50,7 @@ describe('storage:s3', () => { size: 13, mimetype: 'text/plain', meta: {}, - storage_id: 1, + storageId: storage.id, }; // 文件上传和解析是否正常 diff --git a/yarn.lock b/yarn.lock index c59e9c89c0..a45f3c1e52 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3993,15 +3993,14 @@ ajv@^8.0.1: require-from-string "^2.0.2" uri-js "^4.2.2" -ali-oss@^6.8.0: - version "6.16.0" - resolved "https://registry.npmjs.org/ali-oss/-/ali-oss-6.16.0.tgz#3b7fbe10f13fbd535478fc31c7d05aaf4280269b" - integrity sha512-tK/+yEKtBBD+kMoHABxg6lCgC+Ad9HNjCln7qdL6LRYbUm+FFTKJubC4hT2FIooMBDb9tnI7My4MVreKnbJQRg== +ali-oss@^6.16.0: + version "6.17.1" + resolved "https://registry.yarnpkg.com/ali-oss/-/ali-oss-6.17.1.tgz#3e88738ec01111a26a2b967cf857d97050886156" + integrity sha512-v2oT3UhSJTH/LrsscVvi7iEGrnundydNaFzpYAKatqOl4JNcBV4UiwtlJU+ZHLys040JH2k+CutznA0GoE+P2w== dependencies: address "^1.0.0" agentkeepalive "^3.4.1" bowser "^1.6.0" - co-defer "^1.0.0" copy-to "^2.0.1" dateformat "^2.0.0" debug "^2.2.0" @@ -4011,7 +4010,7 @@ ali-oss@^6.8.0: humanize-ms "^1.2.0" is-type-of "^1.0.0" js-base64 "^2.5.2" - jstoxml "^0.2.3" + jstoxml "^2.0.0" merge-descriptors "^1.0.1" mime "^2.4.5" mz-modules "^2.1.0" @@ -5389,11 +5388,6 @@ co-body@^6.0.0: raw-body "^2.3.3" type-is "^1.6.16" -co-defer@^1.0.0: - version "1.0.0" - resolved "https://registry.npmjs.org/co-defer/-/co-defer-1.0.0.tgz#3e4a787a8eed6b0a21ee287c094f7e8de0d3c818" - integrity sha1-Pkp4eo7tawoh7ih8CU9+jeDTyBg= - co@^4.6.0: version "4.6.0" resolved "https://registry.npmjs.org/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" @@ -10063,10 +10057,10 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" -jstoxml@^0.2.3: - version "0.2.4" - resolved "https://registry.npmjs.org/jstoxml/-/jstoxml-0.2.4.tgz#ff3fb67856883a032953c7ce8ce7486210f48447" - integrity sha1-/z+2eFaIOgMpU8fOjOdIYhD0hEc= +jstoxml@^2.0.0: + version "2.2.9" + resolved "https://registry.yarnpkg.com/jstoxml/-/jstoxml-2.2.9.tgz#2eebd5e55383fe66a375022ca0aa88f77bc4fb84" + integrity sha512-OYWlK0j+roh+eyaMROlNbS5cd5R25Y+IUpdl7cNdB8HNrkgwQzIS7L9MegxOiWNBj9dQhA/yAxiMwCC5mwNoBw== "jsx-ast-utils@^2.4.1 || ^3.0.0": version "3.2.1" @@ -11278,12 +11272,12 @@ ms@2.1.2: resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -multer-aliyun-oss@1.1.1: - version "1.1.1" - resolved "https://registry.npmjs.org/multer-aliyun-oss/-/multer-aliyun-oss-1.1.1.tgz#7d6c22989b8755205edbc4bcc233e08e5d13e2e1" - integrity sha512-BcXibwKeHs2amI10ciIAGYWUQUZAX3sFJ3LIZJJsD0AN1xpF+ko2ruZQe01i47czL5sJaIxtRvRpYsVRTQmBaQ== +multer-aliyun-oss@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/multer-aliyun-oss/-/multer-aliyun-oss-2.1.1.tgz#7b6b41385fce2905e8e258a7e68b453ef3982fa0" + integrity sha512-EfDlv2oUZS94+VULybEo8rSlGTsV3YphmCAMT8/nMWBleQDjLMeV7tCK6dXe2Lj+yqRjaTHyuOMhbT5i4voHOQ== dependencies: - ali-oss "^6.8.0" + ali-oss "^6.16.0" multer-s3@^2.10.0: version "2.10.0"