@nocobase/plugin-file-manager 1.7.0-beta.3 → 1.7.0-beta.31
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/client/index.d.ts +13 -0
- package/dist/client/index.js +1 -1
- package/dist/{server/FileModel.d.ts → common/constants.d.ts} +1 -4
- package/dist/common/constants.js +36 -0
- package/dist/externalVersion.js +11 -10
- package/dist/locale/de-DE.json +1 -1
- package/dist/locale/it-IT.json +4 -7
- package/dist/locale/ja-JP.json +1 -1
- package/dist/locale/nl-NL.json +35 -17
- package/dist/locale/zh-CN.json +1 -1
- package/dist/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +834 -834
- 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/index.js +3 -3
- package/dist/node_modules/multer-aliyun-oss/package.json +1 -1
- package/dist/node_modules/multer-cos/index.js +5 -5
- package/dist/node_modules/multer-cos/package.json +1 -1
- package/dist/node_modules/multer-s3/index.js +837 -837
- package/dist/node_modules/multer-s3/package.json +1 -1
- package/dist/node_modules/url-join/.travis.yml +5 -0
- package/dist/node_modules/url-join/LICENSE +21 -0
- package/dist/node_modules/url-join/bin/changelog +28 -0
- package/dist/node_modules/url-join/lib/url-join.js +1 -0
- package/dist/node_modules/url-join/package.json +1 -0
- package/dist/node_modules/url-join/test/tests.js +151 -0
- package/dist/server/actions/attachments.d.ts +0 -11
- package/dist/server/actions/attachments.js +21 -39
- package/dist/server/actions/index.js +19 -0
- package/dist/server/actions/storages.js +4 -1
- package/dist/server/collections/storages.js +8 -4
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +3 -0
- package/dist/server/server.d.ts +12 -6
- package/dist/server/server.js +128 -56
- package/dist/server/storages/ali-oss.js +2 -1
- package/dist/server/storages/index.d.ts +18 -5
- package/dist/server/storages/index.js +68 -2
- package/dist/server/storages/local.d.ts +7 -1
- package/dist/server/storages/local.js +23 -5
- package/dist/server/storages/s3.d.ts +4 -0
- package/dist/server/storages/s3.js +36 -12
- package/dist/server/storages/tx-cos.js +4 -4
- package/dist/server/utils.d.ts +3 -1
- package/dist/server/utils.js +25 -2
- package/package.json +9 -7
- package/dist/server/FileModel.js +0 -58
package/dist/server/utils.js
CHANGED
|
@@ -37,12 +37,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
37
37
|
var utils_exports = {};
|
|
38
38
|
__export(utils_exports, {
|
|
39
39
|
cloudFilenameGetter: () => cloudFilenameGetter,
|
|
40
|
+
encodeURL: () => encodeURL,
|
|
41
|
+
ensureUrlEncoded: () => ensureUrlEncoded,
|
|
40
42
|
getFileKey: () => getFileKey,
|
|
41
43
|
getFilename: () => getFilename
|
|
42
44
|
});
|
|
43
45
|
module.exports = __toCommonJS(utils_exports);
|
|
44
|
-
var import_path = __toESM(require("path"));
|
|
45
46
|
var import_utils = require("@nocobase/utils");
|
|
47
|
+
var import_path = __toESM(require("path"));
|
|
48
|
+
var import_url_join = __toESM(require("url-join"));
|
|
46
49
|
function getFilename(req, file, cb) {
|
|
47
50
|
const originalname = Buffer.from(file.originalname, "binary").toString("utf8");
|
|
48
51
|
const baseName = import_path.default.basename(originalname.replace(/[<>?*|:"\\/]/g, "-"), import_path.default.extname(originalname));
|
|
@@ -57,11 +60,31 @@ const cloudFilenameGetter = (storage) => (req, file, cb) => {
|
|
|
57
60
|
});
|
|
58
61
|
};
|
|
59
62
|
function getFileKey(record) {
|
|
60
|
-
return
|
|
63
|
+
return (0, import_url_join.default)(record.path || "", record.filename).replace(/^\//, "");
|
|
64
|
+
}
|
|
65
|
+
function ensureUrlEncoded(value) {
|
|
66
|
+
try {
|
|
67
|
+
if (decodeURIComponent(value) !== value) {
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
} catch (e) {
|
|
71
|
+
return encodeURIComponent(value);
|
|
72
|
+
}
|
|
73
|
+
return encodeURIComponent(value);
|
|
74
|
+
}
|
|
75
|
+
function encodePathKeepSlash(path2) {
|
|
76
|
+
return path2.split("/").map((segment) => ensureUrlEncoded(segment)).join("/");
|
|
77
|
+
}
|
|
78
|
+
function encodeURL(url) {
|
|
79
|
+
const parsedUrl = new URL(url);
|
|
80
|
+
parsedUrl.pathname = encodePathKeepSlash(parsedUrl.pathname);
|
|
81
|
+
return parsedUrl.toString();
|
|
61
82
|
}
|
|
62
83
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
84
|
0 && (module.exports = {
|
|
64
85
|
cloudFilenameGetter,
|
|
86
|
+
encodeURL,
|
|
87
|
+
ensureUrlEncoded,
|
|
65
88
|
getFileKey,
|
|
66
89
|
getFilename
|
|
67
90
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-file-manager",
|
|
3
|
-
"version": "1.7.0-beta.
|
|
3
|
+
"version": "1.7.0-beta.31",
|
|
4
4
|
"displayName": "File manager",
|
|
5
5
|
"displayName.zh-CN": "文件管理器",
|
|
6
6
|
"description": "Provides files storage services with files collection template and attachment field.",
|
|
@@ -10,26 +10,28 @@
|
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/file-manager",
|
|
11
11
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/file-manager",
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@aws-sdk/client-s3": "
|
|
13
|
+
"@aws-sdk/client-s3": "3.750.0",
|
|
14
14
|
"@formily/antd-v5": "1.x",
|
|
15
15
|
"@formily/core": "2.x",
|
|
16
16
|
"@formily/react": "2.x",
|
|
17
17
|
"@formily/shared": "2.x",
|
|
18
|
-
"@koa/multer": "^3.
|
|
19
|
-
"@types/koa-multer": "^1.0.
|
|
18
|
+
"@koa/multer": "^3.1.0",
|
|
19
|
+
"@types/koa-multer": "^1.0.4",
|
|
20
20
|
"@types/multer": "^1.4.5",
|
|
21
21
|
"antd": "5.x",
|
|
22
|
+
"axios": "^1.7.0",
|
|
22
23
|
"cos-nodejs-sdk-v5": "^2.11.14",
|
|
23
24
|
"koa-static": "^5.0.0",
|
|
24
25
|
"mime-match": "^1.0.2",
|
|
25
26
|
"mkdirp": "~0.5.4",
|
|
26
|
-
"multer": "^1.4.2",
|
|
27
|
+
"multer": "^1.4.5-lts.2",
|
|
27
28
|
"multer-aliyun-oss": "2.1.3",
|
|
28
29
|
"multer-cos": "^1.0.3",
|
|
29
30
|
"multer-s3": "^3.0.1",
|
|
30
31
|
"react": "^18.2.0",
|
|
31
32
|
"react-i18next": "^11.15.1",
|
|
32
|
-
"supertest": "^6.1.6"
|
|
33
|
+
"supertest": "^6.1.6",
|
|
34
|
+
"url-join": "4.0.1"
|
|
33
35
|
},
|
|
34
36
|
"peerDependencies": {
|
|
35
37
|
"@nocobase/actions": "1.x",
|
|
@@ -43,5 +45,5 @@
|
|
|
43
45
|
"Collections",
|
|
44
46
|
"Collection fields"
|
|
45
47
|
],
|
|
46
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "84bf8bcfeeaf3a05086e24cef00507ca209ac3c5"
|
|
47
49
|
}
|
package/dist/server/FileModel.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var FileModel_exports = {};
|
|
28
|
-
__export(FileModel_exports, {
|
|
29
|
-
FileModel: () => FileModel
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(FileModel_exports);
|
|
32
|
-
var import_database = require("@nocobase/database");
|
|
33
|
-
var import_constants = require("../constants");
|
|
34
|
-
const currentStorage = [import_constants.STORAGE_TYPE_LOCAL, import_constants.STORAGE_TYPE_ALI_OSS, import_constants.STORAGE_TYPE_S3, import_constants.STORAGE_TYPE_TX_COS];
|
|
35
|
-
class FileModel extends import_database.Model {
|
|
36
|
-
toJSON() {
|
|
37
|
-
var _a, _b, _c, _d, _e;
|
|
38
|
-
const json = super.toJSON();
|
|
39
|
-
const fileStorages = (_a = this.constructor["database"]) == null ? void 0 : _a["_fileStorages"];
|
|
40
|
-
if (json.storageId && fileStorages && fileStorages.has(json.storageId)) {
|
|
41
|
-
const storage = fileStorages.get(json.storageId);
|
|
42
|
-
if (currentStorage.includes(storage == null ? void 0 : storage.type) && ((_b = storage == null ? void 0 : storage.options) == null ? void 0 : _b.thumbnailRule)) {
|
|
43
|
-
json["preview"] = `${json["url"]}${((_c = storage == null ? void 0 : storage.options) == null ? void 0 : _c.thumbnailRule) || ""}`;
|
|
44
|
-
}
|
|
45
|
-
if ((_d = storage == null ? void 0 : storage.options) == null ? void 0 : _d.thumbnailRule) {
|
|
46
|
-
json["thumbnailRule"] = (_e = storage == null ? void 0 : storage.options) == null ? void 0 : _e.thumbnailRule;
|
|
47
|
-
}
|
|
48
|
-
if ((storage == null ? void 0 : storage.type) === "local" && process.env.APP_PUBLIC_PATH) {
|
|
49
|
-
json["url"] = process.env.APP_PUBLIC_PATH.replace(/\/$/g, "") + json.url;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return json;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
-
0 && (module.exports = {
|
|
57
|
-
FileModel
|
|
58
|
-
});
|