@nocobase/plugin-file-manager 1.6.0-beta.10 → 1.6.0-beta.11
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/dist/externalVersion.js +6 -6
- package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
- package/dist/node_modules/mime-match/package.json +1 -1
- package/dist/node_modules/mkdirp/package.json +1 -1
- package/dist/node_modules/multer-aliyun-oss/package.json +1 -1
- package/dist/node_modules/multer-cos/package.json +1 -1
- package/dist/node_modules/multer-s3/package.json +1 -1
- package/dist/server/actions/attachments.d.ts +11 -1
- package/dist/server/actions/attachments.js +8 -6
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +0 -2
- package/dist/server/server.d.ts +15 -4
- package/dist/server/server.js +29 -29
- package/dist/server/storages/ali-oss.d.ts +3 -3
- package/dist/server/storages/ali-oss.js +10 -10
- package/dist/server/storages/index.d.ts +13 -12
- package/dist/server/storages/index.js +8 -1
- package/dist/server/storages/local.d.ts +4 -3
- package/dist/server/storages/local.js +15 -12
- package/dist/server/storages/s3.d.ts +4 -4
- package/dist/server/storages/s3.js +21 -21
- package/dist/server/storages/tx-cos.d.ts +4 -4
- package/dist/server/storages/tx-cos.js +16 -16
- package/package.json +2 -2
package/dist/externalVersion.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.6.0-beta.
|
|
11
|
+
"@nocobase/client": "1.6.0-beta.11",
|
|
12
12
|
"react": "18.2.0",
|
|
13
13
|
"antd": "5.12.8",
|
|
14
14
|
"@ant-design/icons": "5.2.6",
|
|
@@ -18,10 +18,10 @@ module.exports = {
|
|
|
18
18
|
"@formily/antd-v5": "1.1.9",
|
|
19
19
|
"@formily/core": "2.3.0",
|
|
20
20
|
"@formily/react": "2.3.0",
|
|
21
|
-
"@nocobase/database": "1.6.0-beta.
|
|
21
|
+
"@nocobase/database": "1.6.0-beta.11",
|
|
22
22
|
"multer": "1.4.4",
|
|
23
|
-
"@nocobase/server": "1.6.0-beta.
|
|
24
|
-
"@nocobase/utils": "1.6.0-beta.
|
|
25
|
-
"@nocobase/test": "1.6.0-beta.
|
|
26
|
-
"@nocobase/actions": "1.6.0-beta.
|
|
23
|
+
"@nocobase/server": "1.6.0-beta.11",
|
|
24
|
+
"@nocobase/utils": "1.6.0-beta.11",
|
|
25
|
+
"@nocobase/test": "1.6.0-beta.11",
|
|
26
|
+
"@nocobase/actions": "1.6.0-beta.11"
|
|
27
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@aws-sdk/client-s3","description":"AWS SDK for JavaScript S3 Client for Node.js, Browser and React Native","version":"3.750.0","scripts":{"build":"concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'","build:cjs":"node ../../scripts/compilation/inline client-s3","build:es":"tsc -p tsconfig.es.json","build:include:deps":"lerna run --scope $npm_package_name --include-dependencies build","build:types":"tsc -p tsconfig.types.json","build:types:downlevel":"downlevel-dts dist-types dist-types/ts3.4","clean":"rimraf ./dist-* && rimraf *.tsbuildinfo","extract:docs":"api-extractor run --local","generate:client":"node ../../scripts/generate-clients/single-service --solo s3","test":"yarn g:vitest run","test:browser":"node ./test/browser-build/esbuild && yarn g:vitest run -c vitest.config.browser.ts","test:browser:watch":"node ./test/browser-build/esbuild && yarn g:vitest watch -c vitest.config.browser.ts","test:e2e":"yarn g:vitest run -c vitest.config.e2e.ts && yarn test:browser","test:e2e:watch":"yarn g:vitest watch -c vitest.config.e2e.ts","test:watch":"yarn g:vitest watch"},"main":"./dist-cjs/index.js","types":"./dist-types/index.d.ts","module":"./dist-es/index.js","sideEffects":false,"dependencies":{"@aws-crypto/sha1-browser":"5.2.0","@aws-crypto/sha256-browser":"5.2.0","@aws-crypto/sha256-js":"5.2.0","@aws-sdk/core":"3.750.0","@aws-sdk/credential-provider-node":"3.750.0","@aws-sdk/middleware-bucket-endpoint":"3.734.0","@aws-sdk/middleware-expect-continue":"3.734.0","@aws-sdk/middleware-flexible-checksums":"3.750.0","@aws-sdk/middleware-host-header":"3.734.0","@aws-sdk/middleware-location-constraint":"3.734.0","@aws-sdk/middleware-logger":"3.734.0","@aws-sdk/middleware-recursion-detection":"3.734.0","@aws-sdk/middleware-sdk-s3":"3.750.0","@aws-sdk/middleware-ssec":"3.734.0","@aws-sdk/middleware-user-agent":"3.750.0","@aws-sdk/region-config-resolver":"3.734.0","@aws-sdk/signature-v4-multi-region":"3.750.0","@aws-sdk/types":"3.734.0","@aws-sdk/util-endpoints":"3.743.0","@aws-sdk/util-user-agent-browser":"3.734.0","@aws-sdk/util-user-agent-node":"3.750.0","@aws-sdk/xml-builder":"3.734.0","@smithy/config-resolver":"^4.0.1","@smithy/core":"^3.1.4","@smithy/eventstream-serde-browser":"^4.0.1","@smithy/eventstream-serde-config-resolver":"^4.0.1","@smithy/eventstream-serde-node":"^4.0.1","@smithy/fetch-http-handler":"^5.0.1","@smithy/hash-blob-browser":"^4.0.1","@smithy/hash-node":"^4.0.1","@smithy/hash-stream-node":"^4.0.1","@smithy/invalid-dependency":"^4.0.1","@smithy/md5-js":"^4.0.1","@smithy/middleware-content-length":"^4.0.1","@smithy/middleware-endpoint":"^4.0.5","@smithy/middleware-retry":"^4.0.6","@smithy/middleware-serde":"^4.0.2","@smithy/middleware-stack":"^4.0.1","@smithy/node-config-provider":"^4.0.1","@smithy/node-http-handler":"^4.0.2","@smithy/protocol-http":"^5.0.1","@smithy/smithy-client":"^4.1.5","@smithy/types":"^4.1.0","@smithy/url-parser":"^4.0.1","@smithy/util-base64":"^4.0.0","@smithy/util-body-length-browser":"^4.0.0","@smithy/util-body-length-node":"^4.0.0","@smithy/util-defaults-mode-browser":"^4.0.6","@smithy/util-defaults-mode-node":"^4.0.6","@smithy/util-endpoints":"^3.0.1","@smithy/util-middleware":"^4.0.1","@smithy/util-retry":"^4.0.1","@smithy/util-stream":"^4.1.1","@smithy/util-utf8":"^4.0.0","@smithy/util-waiter":"^4.0.2","tslib":"^2.6.2"},"devDependencies":{"@aws-sdk/signature-v4-crt":"3.750.0","@tsconfig/node18":"18.2.4","@types/node":"^18.19.69","concurrently":"7.0.0","downlevel-dts":"0.10.1","rimraf":"3.0.2","typescript":"~5.2.2"},"engines":{"node":">=18.0.0"},"typesVersions":{"<4.0":{"dist-types/*":["dist-types/ts3.4/*"]}},"files":["dist-*/**"],"author":{"name":"AWS SDK for JavaScript Team","url":"https://aws.amazon.com/javascript/"},"license":"Apache-2.0","browser":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.browser"},"react-native":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.native"},"homepage":"https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-s3","repository":{"type":"git","url":"https://github.com/aws/aws-sdk-js-v3.git","directory":"clients/client-s3"},"_lastModified":"2025-02-
|
|
1
|
+
{"name":"@aws-sdk/client-s3","description":"AWS SDK for JavaScript S3 Client for Node.js, Browser and React Native","version":"3.750.0","scripts":{"build":"concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'","build:cjs":"node ../../scripts/compilation/inline client-s3","build:es":"tsc -p tsconfig.es.json","build:include:deps":"lerna run --scope $npm_package_name --include-dependencies build","build:types":"tsc -p tsconfig.types.json","build:types:downlevel":"downlevel-dts dist-types dist-types/ts3.4","clean":"rimraf ./dist-* && rimraf *.tsbuildinfo","extract:docs":"api-extractor run --local","generate:client":"node ../../scripts/generate-clients/single-service --solo s3","test":"yarn g:vitest run","test:browser":"node ./test/browser-build/esbuild && yarn g:vitest run -c vitest.config.browser.ts","test:browser:watch":"node ./test/browser-build/esbuild && yarn g:vitest watch -c vitest.config.browser.ts","test:e2e":"yarn g:vitest run -c vitest.config.e2e.ts && yarn test:browser","test:e2e:watch":"yarn g:vitest watch -c vitest.config.e2e.ts","test:watch":"yarn g:vitest watch"},"main":"./dist-cjs/index.js","types":"./dist-types/index.d.ts","module":"./dist-es/index.js","sideEffects":false,"dependencies":{"@aws-crypto/sha1-browser":"5.2.0","@aws-crypto/sha256-browser":"5.2.0","@aws-crypto/sha256-js":"5.2.0","@aws-sdk/core":"3.750.0","@aws-sdk/credential-provider-node":"3.750.0","@aws-sdk/middleware-bucket-endpoint":"3.734.0","@aws-sdk/middleware-expect-continue":"3.734.0","@aws-sdk/middleware-flexible-checksums":"3.750.0","@aws-sdk/middleware-host-header":"3.734.0","@aws-sdk/middleware-location-constraint":"3.734.0","@aws-sdk/middleware-logger":"3.734.0","@aws-sdk/middleware-recursion-detection":"3.734.0","@aws-sdk/middleware-sdk-s3":"3.750.0","@aws-sdk/middleware-ssec":"3.734.0","@aws-sdk/middleware-user-agent":"3.750.0","@aws-sdk/region-config-resolver":"3.734.0","@aws-sdk/signature-v4-multi-region":"3.750.0","@aws-sdk/types":"3.734.0","@aws-sdk/util-endpoints":"3.743.0","@aws-sdk/util-user-agent-browser":"3.734.0","@aws-sdk/util-user-agent-node":"3.750.0","@aws-sdk/xml-builder":"3.734.0","@smithy/config-resolver":"^4.0.1","@smithy/core":"^3.1.4","@smithy/eventstream-serde-browser":"^4.0.1","@smithy/eventstream-serde-config-resolver":"^4.0.1","@smithy/eventstream-serde-node":"^4.0.1","@smithy/fetch-http-handler":"^5.0.1","@smithy/hash-blob-browser":"^4.0.1","@smithy/hash-node":"^4.0.1","@smithy/hash-stream-node":"^4.0.1","@smithy/invalid-dependency":"^4.0.1","@smithy/md5-js":"^4.0.1","@smithy/middleware-content-length":"^4.0.1","@smithy/middleware-endpoint":"^4.0.5","@smithy/middleware-retry":"^4.0.6","@smithy/middleware-serde":"^4.0.2","@smithy/middleware-stack":"^4.0.1","@smithy/node-config-provider":"^4.0.1","@smithy/node-http-handler":"^4.0.2","@smithy/protocol-http":"^5.0.1","@smithy/smithy-client":"^4.1.5","@smithy/types":"^4.1.0","@smithy/url-parser":"^4.0.1","@smithy/util-base64":"^4.0.0","@smithy/util-body-length-browser":"^4.0.0","@smithy/util-body-length-node":"^4.0.0","@smithy/util-defaults-mode-browser":"^4.0.6","@smithy/util-defaults-mode-node":"^4.0.6","@smithy/util-endpoints":"^3.0.1","@smithy/util-middleware":"^4.0.1","@smithy/util-retry":"^4.0.1","@smithy/util-stream":"^4.1.1","@smithy/util-utf8":"^4.0.0","@smithy/util-waiter":"^4.0.2","tslib":"^2.6.2"},"devDependencies":{"@aws-sdk/signature-v4-crt":"3.750.0","@tsconfig/node18":"18.2.4","@types/node":"^18.19.69","concurrently":"7.0.0","downlevel-dts":"0.10.1","rimraf":"3.0.2","typescript":"~5.2.2"},"engines":{"node":">=18.0.0"},"typesVersions":{"<4.0":{"dist-types/*":["dist-types/ts3.4/*"]}},"files":["dist-*/**"],"author":{"name":"AWS SDK for JavaScript Team","url":"https://aws.amazon.com/javascript/"},"license":"Apache-2.0","browser":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.browser"},"react-native":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.native"},"homepage":"https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-s3","repository":{"type":"git","url":"https://github.com/aws/aws-sdk-js-v3.git","directory":"clients/client-s3"},"_lastModified":"2025-02-24T13:33:05.144Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"mime-match","version":"1.0.2","description":"A simple function to check whether a mimetype matches the specified mimetype (with wildcard support)","main":"index.js","scripts":{"test":"node test.js","gendocs":"gendocs > README.md"},"repository":{"type":"git","url":"https://github.com/DamonOehlman/mime-match.git"},"keywords":["mime","wildcard"],"author":"Damon Oehlman <damon.oehlman@gmail.com>","license":"ISC","bugs":{"url":"https://github.com/DamonOehlman/mime-match/issues"},"homepage":"https://github.com/DamonOehlman/mime-match","dependencies":{"wildcard":"^1.1.0"},"devDependencies":{"tape":"^4.5.1"},"_lastModified":"2025-02-
|
|
1
|
+
{"name":"mime-match","version":"1.0.2","description":"A simple function to check whether a mimetype matches the specified mimetype (with wildcard support)","main":"index.js","scripts":{"test":"node test.js","gendocs":"gendocs > README.md"},"repository":{"type":"git","url":"https://github.com/DamonOehlman/mime-match.git"},"keywords":["mime","wildcard"],"author":"Damon Oehlman <damon.oehlman@gmail.com>","license":"ISC","bugs":{"url":"https://github.com/DamonOehlman/mime-match/issues"},"homepage":"https://github.com/DamonOehlman/mime-match","dependencies":{"wildcard":"^1.1.0"},"devDependencies":{"tape":"^4.5.1"},"_lastModified":"2025-02-24T13:32:58.451Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"mkdirp","description":"Recursively mkdir, like `mkdir -p`","version":"0.5.6","publishConfig":{"tag":"legacy"},"author":"James Halliday <mail@substack.net> (http://substack.net)","main":"index.js","keywords":["mkdir","directory"],"repository":{"type":"git","url":"https://github.com/substack/node-mkdirp.git"},"scripts":{"test":"tap test/*.js"},"dependencies":{"minimist":"^1.2.6"},"devDependencies":{"tap":"^16.0.1"},"bin":"bin/cmd.js","license":"MIT","files":["bin","index.js"],"_lastModified":"2025-02-
|
|
1
|
+
{"name":"mkdirp","description":"Recursively mkdir, like `mkdir -p`","version":"0.5.6","publishConfig":{"tag":"legacy"},"author":"James Halliday <mail@substack.net> (http://substack.net)","main":"index.js","keywords":["mkdir","directory"],"repository":{"type":"git","url":"https://github.com/substack/node-mkdirp.git"},"scripts":{"test":"tap test/*.js"},"dependencies":{"minimist":"^1.2.6"},"devDependencies":{"tap":"^16.0.1"},"bin":"bin/cmd.js","license":"MIT","files":["bin","index.js"],"_lastModified":"2025-02-24T13:33:03.665Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"multer-aliyun-oss","version":"2.1.3","description":"Multer Storage for AliYun OSS","main":"index.js","scripts":{},"author":"AngusYoung","license":"ISC","repository":{"type":"git","url":"git+https://github.com/ay86/multer-aliyun-oss.git"},"keywords":["multer","storage","aliyun","oss"],"dependencies":{"ali-oss":"^6.1.0"},"_lastModified":"2025-02-
|
|
1
|
+
{"name":"multer-aliyun-oss","version":"2.1.3","description":"Multer Storage for AliYun OSS","main":"index.js","scripts":{},"author":"AngusYoung","license":"ISC","repository":{"type":"git","url":"git+https://github.com/ay86/multer-aliyun-oss.git"},"keywords":["multer","storage","aliyun","oss"],"dependencies":{"ali-oss":"^6.1.0"},"_lastModified":"2025-02-24T13:33:03.574Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"_from":"multer-cos","_id":"multer-cos@1.0.2","_inBundle":false,"_integrity":"sha512-4F8P1VTCSNhiem+BFJFLe3Ixco6cIuAQ6j7U+PBRvdbBJRZgq5Q+vaDMMBWJ1HmPGOOP3AyKS5yk2f0nbFoqqA==","_location":"/multer-cos","_phantomChildren":{},"_requested":{"type":"tag","registry":true,"raw":"multer-cos","name":"multer-cos","escapedName":"multer-cos","rawSpec":"","saveSpec":null,"fetchSpec":"latest"},"_requiredBy":["#USER","/"],"_resolved":"https://registry.npmjs.org/multer-cos/-/multer-cos-1.0.2.tgz","_shasum":"95c7c06cdee1b9311675a895481f9d946de6dcf3","_spec":"multer-cos","_where":"/Users/lanbo/workplace/websocket","author":{"name":"lanbosm"},"bugs":{"url":"https://github.com/lanbosm/multer-COS/issues"},"bundleDependencies":false,"deprecated":false,"description":"Streaming multer storage engine for QCloud COS","devDependencies":{"cos-nodejs-sdk-v5":"^2.2.6","dotenv":"^5.0.1","multer":"^1.3.0"},"engines":{"node":">= 6.10.0"},"homepage":"https://github.com/lanbosm/multer-COS#readme","keywords":["express","multer","COS"],"license":"MIT","main":"index.js","name":"multer-cos","repository":{"type":"git","url":"git+ssh://git@github.com/lanbosm/multer-COS.git"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"version":"1.0.3","_lastModified":"2025-02-
|
|
1
|
+
{"_from":"multer-cos","_id":"multer-cos@1.0.2","_inBundle":false,"_integrity":"sha512-4F8P1VTCSNhiem+BFJFLe3Ixco6cIuAQ6j7U+PBRvdbBJRZgq5Q+vaDMMBWJ1HmPGOOP3AyKS5yk2f0nbFoqqA==","_location":"/multer-cos","_phantomChildren":{},"_requested":{"type":"tag","registry":true,"raw":"multer-cos","name":"multer-cos","escapedName":"multer-cos","rawSpec":"","saveSpec":null,"fetchSpec":"latest"},"_requiredBy":["#USER","/"],"_resolved":"https://registry.npmjs.org/multer-cos/-/multer-cos-1.0.2.tgz","_shasum":"95c7c06cdee1b9311675a895481f9d946de6dcf3","_spec":"multer-cos","_where":"/Users/lanbo/workplace/websocket","author":{"name":"lanbosm"},"bugs":{"url":"https://github.com/lanbosm/multer-COS/issues"},"bundleDependencies":false,"deprecated":false,"description":"Streaming multer storage engine for QCloud COS","devDependencies":{"cos-nodejs-sdk-v5":"^2.2.6","dotenv":"^5.0.1","multer":"^1.3.0"},"engines":{"node":">= 6.10.0"},"homepage":"https://github.com/lanbosm/multer-COS#readme","keywords":["express","multer","COS"],"license":"MIT","main":"index.js","name":"multer-cos","repository":{"type":"git","url":"git+ssh://git@github.com/lanbosm/multer-COS.git"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"version":"1.0.3","_lastModified":"2025-02-24T13:33:11.055Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"multer-s3","version":"3.0.1","description":"Streaming multer storage engine for AWS S3","main":"index.js","scripts":{"test":"standard && mocha test/basic.js"},"engines":{"node":">= 12.0.0"},"repository":{"type":"git","url":"git+https://github.com/badunk/multer-s3.git"},"keywords":["multer","s3","amazon","aws"],"author":"badunk","license":"MIT","bugs":{"url":"https://github.com/badunk/multer-s3/issues"},"homepage":"https://github.com/badunk/multer-s3#readme","dependencies":{"@aws-sdk/lib-storage":"^3.46.0","file-type":"^3.3.0","html-comment-regex":"^1.1.2","run-parallel":"^1.1.6"},"peerDependencies":{"@aws-sdk/client-s3":"^3.0.0"},"devDependencies":{"express":"^4.13.1","form-data":"^1.0.0-rc3","mocha":"^2.2.5","multer":"^1.1.0","on-finished":"^2.3.0","standard":"^5.4.1","xtend":"^4.0.1"},"_lastModified":"2025-02-
|
|
1
|
+
{"name":"multer-s3","version":"3.0.1","description":"Streaming multer storage engine for AWS S3","main":"index.js","scripts":{"test":"standard && mocha test/basic.js"},"engines":{"node":">= 12.0.0"},"repository":{"type":"git","url":"git+https://github.com/badunk/multer-s3.git"},"keywords":["multer","s3","amazon","aws"],"author":"badunk","license":"MIT","bugs":{"url":"https://github.com/badunk/multer-s3/issues"},"homepage":"https://github.com/badunk/multer-s3#readme","dependencies":{"@aws-sdk/lib-storage":"^3.46.0","file-type":"^3.3.0","html-comment-regex":"^1.1.2","run-parallel":"^1.1.6"},"peerDependencies":{"@aws-sdk/client-s3":"^3.0.0"},"devDependencies":{"express":"^4.13.1","form-data":"^1.0.0-rc3","mocha":"^2.2.5","multer":"^1.1.0","on-finished":"^2.3.0","standard":"^5.4.1","xtend":"^4.0.1"},"_lastModified":"2025-02-24T13:33:06.750Z"}
|
|
@@ -7,5 +7,15 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { Context, Next } from '@nocobase/actions';
|
|
10
|
-
export declare function getFileData(ctx: Context):
|
|
10
|
+
export declare function getFileData(ctx: Context): {
|
|
11
|
+
title: string;
|
|
12
|
+
filename: string;
|
|
13
|
+
extname: string;
|
|
14
|
+
path: any;
|
|
15
|
+
size: any;
|
|
16
|
+
url: string;
|
|
17
|
+
mimetype: any;
|
|
18
|
+
meta: unknown;
|
|
19
|
+
storageId: any;
|
|
20
|
+
};
|
|
11
21
|
export declare function createMiddleware(ctx: Context, next: Next): Promise<any>;
|
|
@@ -58,13 +58,14 @@ function getFileData(ctx) {
|
|
|
58
58
|
if (!file) {
|
|
59
59
|
return ctx.throw(400, "file validation failed");
|
|
60
60
|
}
|
|
61
|
-
const
|
|
62
|
-
const { [
|
|
61
|
+
const StorageType = ctx.app.pm.get(import__.default).storageTypes.get(storage.type);
|
|
62
|
+
const { [StorageType.filenameKey || "filename"]: name } = file;
|
|
63
63
|
const filename = import_path.default.basename(name);
|
|
64
64
|
const extname = import_path.default.extname(filename);
|
|
65
65
|
const path = (storage.path || "").replace(/^\/|\/$/g, "");
|
|
66
66
|
const baseUrl = storage.baseUrl.replace(/\/+$/, "");
|
|
67
67
|
const pathname = [path, filename].filter(Boolean).join("/");
|
|
68
|
+
const storageInstance = new StorageType(storage);
|
|
68
69
|
return {
|
|
69
70
|
title: Buffer.from(file.originalname, "latin1").toString("utf8").replace(extname, ""),
|
|
70
71
|
filename,
|
|
@@ -78,7 +79,7 @@ function getFileData(ctx) {
|
|
|
78
79
|
// @ts-ignore
|
|
79
80
|
meta: ctx.request.body,
|
|
80
81
|
storageId: storage.id,
|
|
81
|
-
...
|
|
82
|
+
...storageInstance.getFileData ? storageInstance.getFileData(file) : {}
|
|
82
83
|
};
|
|
83
84
|
}
|
|
84
85
|
async function multipart(ctx, next) {
|
|
@@ -87,18 +88,19 @@ async function multipart(ctx, next) {
|
|
|
87
88
|
ctx.logger.error("[file-manager] no linked or default storage provided");
|
|
88
89
|
return ctx.throw(500);
|
|
89
90
|
}
|
|
90
|
-
const
|
|
91
|
-
if (!
|
|
91
|
+
const StorageType = ctx.app.pm.get(import__.default).storageTypes.get(storage.type);
|
|
92
|
+
if (!StorageType) {
|
|
92
93
|
ctx.logger.error(`[file-manager] storage type "${storage.type}" is not defined`);
|
|
93
94
|
return ctx.throw(500);
|
|
94
95
|
}
|
|
96
|
+
const storageInstance = new StorageType(storage);
|
|
95
97
|
const multerOptions = {
|
|
96
98
|
fileFilter: getFileFilter(storage),
|
|
97
99
|
limits: {
|
|
98
100
|
// 每次只允许提交一个文件
|
|
99
101
|
files: import_constants.LIMIT_FILES
|
|
100
102
|
},
|
|
101
|
-
storage:
|
|
103
|
+
storage: storageInstance.make()
|
|
102
104
|
};
|
|
103
105
|
multerOptions.limits["fileSize"] = Math.min(
|
|
104
106
|
Math.max(import_constants.FILE_SIZE_LIMIT_MIN, storage.rules.size ?? import_constants.FILE_SIZE_LIMIT_DEFAULT),
|
package/dist/server/index.d.ts
CHANGED
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { StorageEngine } from 'multer';
|
|
10
10
|
export * from '../constants';
|
|
11
|
-
export { AttachmentModel, default,
|
|
11
|
+
export { AttachmentModel, default, PluginFileManagerServer, StorageModel } from './server';
|
|
12
12
|
export { StorageType } from './storages';
|
|
13
13
|
export { StorageEngine };
|
package/dist/server/index.js
CHANGED
|
@@ -38,7 +38,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
38
38
|
var server_exports = {};
|
|
39
39
|
__export(server_exports, {
|
|
40
40
|
AttachmentModel: () => import_server.AttachmentModel,
|
|
41
|
-
IStorage: () => import_server.IStorage,
|
|
42
41
|
PluginFileManagerServer: () => import_server.PluginFileManagerServer,
|
|
43
42
|
StorageEngine: () => import_multer.StorageEngine,
|
|
44
43
|
StorageModel: () => import_server.StorageModel,
|
|
@@ -53,7 +52,6 @@ var import_storages = require("./storages");
|
|
|
53
52
|
// Annotate the CommonJS export names for ESM import in node:
|
|
54
53
|
0 && (module.exports = {
|
|
55
54
|
AttachmentModel,
|
|
56
|
-
IStorage,
|
|
57
55
|
PluginFileManagerServer,
|
|
58
56
|
StorageEngine,
|
|
59
57
|
StorageModel,
|
package/dist/server/server.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { Plugin } from '@nocobase/server';
|
|
10
10
|
import { Registry } from '@nocobase/utils';
|
|
11
11
|
import { Model, Transactionable } from '@nocobase/database';
|
|
12
|
-
import {
|
|
12
|
+
import { AttachmentModel, StorageClassType, StorageModel } from './storages';
|
|
13
13
|
export type * from './storages';
|
|
14
14
|
export type FileRecordOptions = {
|
|
15
15
|
collectionName: string;
|
|
@@ -23,13 +23,23 @@ export type UploadFileOptions = {
|
|
|
23
23
|
documentRoot?: string;
|
|
24
24
|
};
|
|
25
25
|
export declare class PluginFileManagerServer extends Plugin {
|
|
26
|
-
storageTypes: Registry<
|
|
26
|
+
storageTypes: Registry<StorageClassType>;
|
|
27
27
|
storagesCache: Map<number, StorageModel>;
|
|
28
28
|
afterDestroy: (record: Model, options: any) => Promise<void>;
|
|
29
|
-
registerStorageType(type: string,
|
|
29
|
+
registerStorageType(type: string, Type: StorageClassType): void;
|
|
30
30
|
createFileRecord(options: FileRecordOptions): Promise<any>;
|
|
31
31
|
parseStorage(instance: any): any;
|
|
32
|
-
uploadFile(options: UploadFileOptions): Promise<
|
|
32
|
+
uploadFile(options: UploadFileOptions): Promise<{
|
|
33
|
+
title: string;
|
|
34
|
+
filename: string;
|
|
35
|
+
extname: string;
|
|
36
|
+
path: any;
|
|
37
|
+
size: any;
|
|
38
|
+
url: string;
|
|
39
|
+
mimetype: any;
|
|
40
|
+
meta: unknown;
|
|
41
|
+
storageId: any;
|
|
42
|
+
}>;
|
|
33
43
|
loadStorages(options?: {
|
|
34
44
|
transaction: any;
|
|
35
45
|
}): Promise<void>;
|
|
@@ -37,5 +47,6 @@ export declare class PluginFileManagerServer extends Plugin {
|
|
|
37
47
|
handleSyncMessage(message: any): Promise<void>;
|
|
38
48
|
beforeLoad(): Promise<void>;
|
|
39
49
|
load(): Promise<void>;
|
|
50
|
+
getFileURL(file: AttachmentModel): string | Promise<string>;
|
|
40
51
|
}
|
|
41
52
|
export default PluginFileManagerServer;
|
package/dist/server/server.js
CHANGED
|
@@ -75,14 +75,15 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
75
75
|
if (storage == null ? void 0 : storage.paranoid) {
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
-
const
|
|
79
|
-
const
|
|
78
|
+
const Type = this.storageTypes.get(storage.type);
|
|
79
|
+
const storageConfig = new Type(storage);
|
|
80
|
+
const result = await storageConfig.delete([record]);
|
|
80
81
|
if (!result[0]) {
|
|
81
82
|
throw new FileDeleteError("Failed to delete file", record);
|
|
82
83
|
}
|
|
83
84
|
};
|
|
84
|
-
registerStorageType(type,
|
|
85
|
-
this.storageTypes.register(type,
|
|
85
|
+
registerStorageType(type, Type) {
|
|
86
|
+
this.storageTypes.register(type, Type);
|
|
86
87
|
}
|
|
87
88
|
async createFileRecord(options) {
|
|
88
89
|
const { values, storageName, collectionName, filePath, transaction } = options;
|
|
@@ -102,20 +103,13 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
102
103
|
const { storageName, filePath, documentRoot } = options;
|
|
103
104
|
const storageRepository = this.db.getRepository("storages");
|
|
104
105
|
let storageInstance;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (!storageInstance) {
|
|
113
|
-
storageInstance = await storageRepository.findOne({
|
|
114
|
-
filter: {
|
|
115
|
-
default: true
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
106
|
+
storageInstance = await storageRepository.findOne({
|
|
107
|
+
filter: storageName ? {
|
|
108
|
+
name: storageName
|
|
109
|
+
} : {
|
|
110
|
+
default: true
|
|
111
|
+
}
|
|
112
|
+
});
|
|
119
113
|
const fileStream = import_fs.default.createReadStream(filePath);
|
|
120
114
|
if (!storageInstance) {
|
|
121
115
|
throw new Error("[file-manager] no linked or default storage provided");
|
|
@@ -124,11 +118,12 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
124
118
|
if (documentRoot) {
|
|
125
119
|
storageInstance.options["documentRoot"] = documentRoot;
|
|
126
120
|
}
|
|
127
|
-
const
|
|
128
|
-
|
|
121
|
+
const storageType = this.storageTypes.get(storageInstance.type);
|
|
122
|
+
const storage = new storageType(storageInstance);
|
|
123
|
+
if (!storage) {
|
|
129
124
|
throw new Error(`[file-manager] storage type "${storageInstance.type}" is not defined`);
|
|
130
125
|
}
|
|
131
|
-
const engine =
|
|
126
|
+
const engine = storage.make();
|
|
132
127
|
const file = {
|
|
133
128
|
originalname: (0, import_path.basename)(filePath),
|
|
134
129
|
path: filePath,
|
|
@@ -157,19 +152,19 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
157
152
|
this.db["_fileStorages"] = this.storagesCache;
|
|
158
153
|
}
|
|
159
154
|
async install() {
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
155
|
+
const defaultStorageType = this.storageTypes.get(DEFAULT_STORAGE_TYPE);
|
|
156
|
+
if (defaultStorageType) {
|
|
162
157
|
const Storage = this.db.getCollection("storages");
|
|
163
158
|
if (await Storage.repository.findOne({
|
|
164
159
|
filter: {
|
|
165
|
-
name:
|
|
160
|
+
name: defaultStorageType.defaults().name
|
|
166
161
|
}
|
|
167
162
|
})) {
|
|
168
163
|
return;
|
|
169
164
|
}
|
|
170
165
|
await Storage.repository.create({
|
|
171
166
|
values: {
|
|
172
|
-
...
|
|
167
|
+
...defaultStorageType.defaults(),
|
|
173
168
|
type: DEFAULT_STORAGE_TYPE,
|
|
174
169
|
default: true
|
|
175
170
|
}
|
|
@@ -203,10 +198,10 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
203
198
|
}
|
|
204
199
|
async load() {
|
|
205
200
|
this.db.on("afterDestroy", this.afterDestroy);
|
|
206
|
-
this.storageTypes.register(import_constants.STORAGE_TYPE_LOCAL,
|
|
207
|
-
this.storageTypes.register(import_constants.STORAGE_TYPE_ALI_OSS,
|
|
208
|
-
this.storageTypes.register(import_constants.STORAGE_TYPE_S3,
|
|
209
|
-
this.storageTypes.register(import_constants.STORAGE_TYPE_TX_COS,
|
|
201
|
+
this.storageTypes.register(import_constants.STORAGE_TYPE_LOCAL, import_local.default);
|
|
202
|
+
this.storageTypes.register(import_constants.STORAGE_TYPE_ALI_OSS, import_ali_oss.default);
|
|
203
|
+
this.storageTypes.register(import_constants.STORAGE_TYPE_S3, import_s3.default);
|
|
204
|
+
this.storageTypes.register(import_constants.STORAGE_TYPE_TX_COS, import_tx_cos.default);
|
|
210
205
|
const Storage = this.db.getModel("storages");
|
|
211
206
|
Storage.afterSave((m, { transaction }) => {
|
|
212
207
|
this.storagesCache.set(m.id, m.toJSON());
|
|
@@ -254,6 +249,11 @@ class PluginFileManagerServer extends import_server.Plugin {
|
|
|
254
249
|
this.app.acl.addFixedParams("attachments", "destroy", ownMerger);
|
|
255
250
|
this.app.db.interfaceManager.registerInterfaceType("attachment", import_attachment_interface.AttachmentInterface);
|
|
256
251
|
}
|
|
252
|
+
getFileURL(file) {
|
|
253
|
+
const storage = this.storagesCache.get(file.storageId);
|
|
254
|
+
const storageType = this.storageTypes.get(storage.type);
|
|
255
|
+
return new storageType(storage).getFileURL(file);
|
|
256
|
+
}
|
|
257
257
|
}
|
|
258
258
|
var server_default = PluginFileManagerServer;
|
|
259
259
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { AttachmentModel, StorageType } from '.';
|
|
10
10
|
export default class extends StorageType {
|
|
11
|
-
|
|
12
|
-
defaults(): {
|
|
11
|
+
static defaults(): {
|
|
13
12
|
title: string;
|
|
14
13
|
type: string;
|
|
15
14
|
name: string;
|
|
@@ -21,5 +20,6 @@ export default class extends StorageType {
|
|
|
21
20
|
bucket: string;
|
|
22
21
|
};
|
|
23
22
|
};
|
|
24
|
-
|
|
23
|
+
make(): any;
|
|
24
|
+
delete(records: AttachmentModel[]): Promise<[number, AttachmentModel[]]>;
|
|
25
25
|
}
|
|
@@ -33,14 +33,7 @@ var import__ = require(".");
|
|
|
33
33
|
var import_constants = require("../../constants");
|
|
34
34
|
var import_utils = require("../utils");
|
|
35
35
|
class ali_oss_default extends import__.StorageType {
|
|
36
|
-
|
|
37
|
-
const createAliOssStorage = require("multer-aliyun-oss");
|
|
38
|
-
return new createAliOssStorage({
|
|
39
|
-
config: storage.options,
|
|
40
|
-
filename: (0, import_utils.cloudFilenameGetter)(storage)
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
defaults() {
|
|
36
|
+
static defaults() {
|
|
44
37
|
return {
|
|
45
38
|
title: "\u963F\u91CC\u4E91\u5BF9\u8C61\u5B58\u50A8",
|
|
46
39
|
type: import_constants.STORAGE_TYPE_ALI_OSS,
|
|
@@ -54,8 +47,15 @@ class ali_oss_default extends import__.StorageType {
|
|
|
54
47
|
}
|
|
55
48
|
};
|
|
56
49
|
}
|
|
57
|
-
|
|
58
|
-
const
|
|
50
|
+
make() {
|
|
51
|
+
const createAliOssStorage = require("multer-aliyun-oss");
|
|
52
|
+
return new createAliOssStorage({
|
|
53
|
+
config: this.storage.options,
|
|
54
|
+
filename: (0, import_utils.cloudFilenameGetter)(this.storage)
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async delete(records) {
|
|
58
|
+
const { client } = this.make();
|
|
59
59
|
const { deleted } = await client.deleteMulti(records.map(import_utils.getFileKey));
|
|
60
60
|
return [deleted.length, records.filter((record) => !deleted.find((item) => item.Key === (0, import_utils.getFileKey)(record)))];
|
|
61
61
|
}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
import Application from '@nocobase/server';
|
|
10
9
|
import { StorageEngine } from 'multer';
|
|
11
10
|
export interface StorageModel {
|
|
12
11
|
id?: number;
|
|
@@ -24,21 +23,23 @@ export interface AttachmentModel {
|
|
|
24
23
|
title: string;
|
|
25
24
|
filename: string;
|
|
26
25
|
path: string;
|
|
26
|
+
url: string;
|
|
27
|
+
storageId: number;
|
|
27
28
|
}
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
export declare abstract class StorageType {
|
|
30
|
+
storage: StorageModel;
|
|
31
|
+
static defaults(): StorageModel;
|
|
32
|
+
static filenameKey?: string;
|
|
33
|
+
constructor(storage: StorageModel);
|
|
34
|
+
abstract make(): StorageEngine;
|
|
35
|
+
abstract delete(records: AttachmentModel[]): [number, AttachmentModel[]] | Promise<[number, AttachmentModel[]]>;
|
|
31
36
|
getFileData?(file: {
|
|
32
37
|
[key: string]: any;
|
|
33
38
|
}): {
|
|
34
39
|
[key: string]: any;
|
|
35
40
|
};
|
|
36
|
-
|
|
37
|
-
defaults(): StorageModel;
|
|
38
|
-
delete(storage: StorageModel, records: AttachmentModel[]): Promise<[number, AttachmentModel[]]>;
|
|
39
|
-
}
|
|
40
|
-
export declare abstract class StorageType implements IStorage {
|
|
41
|
-
abstract make(storage: StorageModel): StorageEngine;
|
|
42
|
-
abstract delete(storage: StorageModel, records: AttachmentModel[]): Promise<[number, AttachmentModel[]]>;
|
|
43
|
-
defaults(): StorageModel;
|
|
41
|
+
getFileURL(file: AttachmentModel): string | Promise<string>;
|
|
44
42
|
}
|
|
43
|
+
export type StorageClassType = {
|
|
44
|
+
new (storage: StorageModel): StorageType;
|
|
45
|
+
} & typeof StorageType;
|
|
@@ -30,9 +30,16 @@ __export(storages_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(storages_exports);
|
|
32
32
|
class StorageType {
|
|
33
|
-
|
|
33
|
+
constructor(storage) {
|
|
34
|
+
this.storage = storage;
|
|
35
|
+
}
|
|
36
|
+
static defaults() {
|
|
34
37
|
return {};
|
|
35
38
|
}
|
|
39
|
+
static filenameKey;
|
|
40
|
+
getFileURL(file) {
|
|
41
|
+
return file.url;
|
|
42
|
+
}
|
|
36
43
|
}
|
|
37
44
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
45
|
0 && (module.exports = {
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
import multer from 'multer';
|
|
10
10
|
import { AttachmentModel, StorageType } from '.';
|
|
11
11
|
export default class extends StorageType {
|
|
12
|
-
|
|
13
|
-
defaults(): {
|
|
12
|
+
static defaults(): {
|
|
14
13
|
title: string;
|
|
15
14
|
type: string;
|
|
16
15
|
name: string;
|
|
@@ -22,5 +21,7 @@ export default class extends StorageType {
|
|
|
22
21
|
size: number;
|
|
23
22
|
};
|
|
24
23
|
};
|
|
25
|
-
|
|
24
|
+
make(): multer.StorageEngine;
|
|
25
|
+
delete(records: AttachmentModel[]): Promise<[number, AttachmentModel[]]>;
|
|
26
|
+
getFileURL(file: AttachmentModel): string;
|
|
26
27
|
}
|
|
@@ -51,16 +51,7 @@ function getDocumentRoot(storage) {
|
|
|
51
51
|
return import_path.default.resolve(import_path.default.isAbsolute(documentRoot) ? documentRoot : import_path.default.join(process.cwd(), documentRoot));
|
|
52
52
|
}
|
|
53
53
|
class local_default extends import__.StorageType {
|
|
54
|
-
|
|
55
|
-
return import_multer.default.diskStorage({
|
|
56
|
-
destination: function(req, file, cb) {
|
|
57
|
-
const destPath = import_path.default.join(getDocumentRoot(storage), storage.path);
|
|
58
|
-
(0, import_mkdirp.default)(destPath, (err) => cb(err, destPath));
|
|
59
|
-
},
|
|
60
|
-
filename: import_utils.getFilename
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
defaults() {
|
|
54
|
+
static defaults() {
|
|
64
55
|
return {
|
|
65
56
|
title: "Local storage",
|
|
66
57
|
type: import_constants.STORAGE_TYPE_LOCAL,
|
|
@@ -74,8 +65,17 @@ class local_default extends import__.StorageType {
|
|
|
74
65
|
}
|
|
75
66
|
};
|
|
76
67
|
}
|
|
77
|
-
|
|
78
|
-
|
|
68
|
+
make() {
|
|
69
|
+
return import_multer.default.diskStorage({
|
|
70
|
+
destination: (req, file, cb) => {
|
|
71
|
+
const destPath = import_path.default.join(getDocumentRoot(this.storage), this.storage.path);
|
|
72
|
+
(0, import_mkdirp.default)(destPath, (err) => cb(err, destPath));
|
|
73
|
+
},
|
|
74
|
+
filename: import_utils.getFilename
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async delete(records) {
|
|
78
|
+
const documentRoot = getDocumentRoot(this.storage);
|
|
79
79
|
let count = 0;
|
|
80
80
|
const undeleted = [];
|
|
81
81
|
await records.reduce(
|
|
@@ -97,4 +97,7 @@ class local_default extends import__.StorageType {
|
|
|
97
97
|
);
|
|
98
98
|
return [count, undeleted];
|
|
99
99
|
}
|
|
100
|
+
getFileURL(file) {
|
|
101
|
+
return process.env.APP_PUBLIC_PATH ? `${process.env.APP_PUBLIC_PATH.replace(/\/$/g, "")}${file.url}` : file.url;
|
|
102
|
+
}
|
|
100
103
|
}
|
|
@@ -8,9 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { AttachmentModel, StorageType } from '.';
|
|
10
10
|
export default class extends StorageType {
|
|
11
|
-
|
|
12
|
-
make(storage: any): any;
|
|
13
|
-
defaults(): {
|
|
11
|
+
static defaults(): {
|
|
14
12
|
title: string;
|
|
15
13
|
name: string;
|
|
16
14
|
type: string;
|
|
@@ -22,5 +20,7 @@ export default class extends StorageType {
|
|
|
22
20
|
bucket: string;
|
|
23
21
|
};
|
|
24
22
|
};
|
|
25
|
-
|
|
23
|
+
static filenameKey: string;
|
|
24
|
+
make(): any;
|
|
25
|
+
delete(records: AttachmentModel[]): Promise<[number, AttachmentModel[]]>;
|
|
26
26
|
}
|
|
@@ -33,11 +33,25 @@ var import__ = require(".");
|
|
|
33
33
|
var import_constants = require("../../constants");
|
|
34
34
|
var import_utils = require("../utils");
|
|
35
35
|
class s3_default extends import__.StorageType {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
static defaults() {
|
|
37
|
+
return {
|
|
38
|
+
title: "AWS S3",
|
|
39
|
+
name: "aws-s3",
|
|
40
|
+
type: import_constants.STORAGE_TYPE_S3,
|
|
41
|
+
baseUrl: process.env.AWS_S3_STORAGE_BASE_URL,
|
|
42
|
+
options: {
|
|
43
|
+
region: process.env.AWS_S3_REGION,
|
|
44
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
45
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
46
|
+
bucket: process.env.AWS_S3_BUCKET
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
static filenameKey = "key";
|
|
51
|
+
make() {
|
|
38
52
|
const { S3Client } = require("@aws-sdk/client-s3");
|
|
39
53
|
const multerS3 = require("multer-s3");
|
|
40
|
-
const { accessKeyId, secretAccessKey, bucket, acl = "public-read", ...options } = storage.options;
|
|
54
|
+
const { accessKeyId, secretAccessKey, bucket, acl = "public-read", ...options } = this.storage.options;
|
|
41
55
|
if (options.endpoint) {
|
|
42
56
|
options.forcePathStyle = true;
|
|
43
57
|
} else {
|
|
@@ -61,29 +75,15 @@ class s3_default extends import__.StorageType {
|
|
|
61
75
|
}
|
|
62
76
|
multerS3.AUTO_CONTENT_TYPE(req, file, cb);
|
|
63
77
|
},
|
|
64
|
-
key: (0, import_utils.cloudFilenameGetter)(storage)
|
|
78
|
+
key: (0, import_utils.cloudFilenameGetter)(this.storage)
|
|
65
79
|
});
|
|
66
80
|
}
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
title: "AWS S3",
|
|
70
|
-
name: "aws-s3",
|
|
71
|
-
type: import_constants.STORAGE_TYPE_S3,
|
|
72
|
-
baseUrl: process.env.AWS_S3_STORAGE_BASE_URL,
|
|
73
|
-
options: {
|
|
74
|
-
region: process.env.AWS_S3_REGION,
|
|
75
|
-
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
76
|
-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
77
|
-
bucket: process.env.AWS_S3_BUCKET
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
async delete(storage, records) {
|
|
81
|
+
async delete(records) {
|
|
82
82
|
const { DeleteObjectsCommand } = require("@aws-sdk/client-s3");
|
|
83
|
-
const { s3 } = this.make(
|
|
83
|
+
const { s3 } = this.make();
|
|
84
84
|
const { Deleted } = await s3.send(
|
|
85
85
|
new DeleteObjectsCommand({
|
|
86
|
-
Bucket: storage.options.bucket,
|
|
86
|
+
Bucket: this.storage.options.bucket,
|
|
87
87
|
Delete: {
|
|
88
88
|
Objects: records.map((record) => ({ Key: (0, import_utils.getFileKey)(record) }))
|
|
89
89
|
}
|
|
@@ -8,9 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { AttachmentModel, StorageType } from '.';
|
|
10
10
|
export default class extends StorageType {
|
|
11
|
-
|
|
12
|
-
make(storage: any): any;
|
|
13
|
-
defaults(): {
|
|
11
|
+
static defaults(): {
|
|
14
12
|
title: string;
|
|
15
13
|
type: string;
|
|
16
14
|
name: string;
|
|
@@ -22,5 +20,7 @@ export default class extends StorageType {
|
|
|
22
20
|
Bucket: string;
|
|
23
21
|
};
|
|
24
22
|
};
|
|
25
|
-
|
|
23
|
+
static filenameKey: string;
|
|
24
|
+
make(): any;
|
|
25
|
+
delete(records: AttachmentModel[]): Promise<[number, AttachmentModel[]]>;
|
|
26
26
|
}
|
|
@@ -34,18 +34,7 @@ var import__ = require(".");
|
|
|
34
34
|
var import_constants = require("../../constants");
|
|
35
35
|
var import_utils = require("../utils");
|
|
36
36
|
class tx_cos_default extends import__.StorageType {
|
|
37
|
-
|
|
38
|
-
make(storage) {
|
|
39
|
-
const createTxCosStorage = require("multer-cos");
|
|
40
|
-
return new createTxCosStorage({
|
|
41
|
-
cos: {
|
|
42
|
-
...storage.options,
|
|
43
|
-
dir: (storage.path ?? "").replace(/\/+$/, "")
|
|
44
|
-
},
|
|
45
|
-
filename: import_utils.getFilename
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
defaults() {
|
|
37
|
+
static defaults() {
|
|
49
38
|
return {
|
|
50
39
|
title: "\u817E\u8BAF\u4E91\u5BF9\u8C61\u5B58\u50A8",
|
|
51
40
|
type: import_constants.STORAGE_TYPE_TX_COS,
|
|
@@ -59,11 +48,22 @@ class tx_cos_default extends import__.StorageType {
|
|
|
59
48
|
}
|
|
60
49
|
};
|
|
61
50
|
}
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
static filenameKey = "url";
|
|
52
|
+
make() {
|
|
53
|
+
const createTxCosStorage = require("multer-cos");
|
|
54
|
+
return new createTxCosStorage({
|
|
55
|
+
cos: {
|
|
56
|
+
...this.storage.options,
|
|
57
|
+
dir: (this.storage.path ?? "").replace(/\/+$/, "")
|
|
58
|
+
},
|
|
59
|
+
filename: import_utils.getFilename
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async delete(records) {
|
|
63
|
+
const { cos } = this.make();
|
|
64
64
|
const { Deleted } = await (0, import_util.promisify)(cos.deleteMultipleObject).call(cos, {
|
|
65
|
-
Region: storage.options.Region,
|
|
66
|
-
Bucket: storage.options.Bucket,
|
|
65
|
+
Region: this.storage.options.Region,
|
|
66
|
+
Bucket: this.storage.options.Bucket,
|
|
67
67
|
Objects: records.map((record) => ({ Key: (0, import_utils.getFileKey)(record) }))
|
|
68
68
|
});
|
|
69
69
|
return [Deleted.length, records.filter((record) => !Deleted.find((item) => item.Key === (0, import_utils.getFileKey)(record)))];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-file-manager",
|
|
3
|
-
"version": "1.6.0-beta.
|
|
3
|
+
"version": "1.6.0-beta.11",
|
|
4
4
|
"displayName": "File manager",
|
|
5
5
|
"displayName.zh-CN": "文件管理器",
|
|
6
6
|
"description": "Provides files storage services with files collection template and attachment field.",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"Collections",
|
|
44
44
|
"Collection fields"
|
|
45
45
|
],
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "6cff97cdc31b9f191aaecb0f0d358c29e87ebde0"
|
|
47
47
|
}
|