@nocobase/plugin-file-manager 1.6.0-beta.9 → 1.6.0

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.
Files changed (64) hide show
  1. package/dist/client/index.js +1 -1
  2. package/dist/externalVersion.js +9 -7
  3. package/dist/locale/it-IT.json +22 -0
  4. package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
  5. package/dist/node_modules/iconv-lite/.github/dependabot.yml +11 -0
  6. package/dist/node_modules/iconv-lite/.idea/codeStyles/Project.xml +47 -0
  7. package/dist/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +5 -0
  8. package/dist/node_modules/iconv-lite/.idea/iconv-lite.iml +12 -0
  9. package/dist/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +6 -0
  10. package/dist/node_modules/iconv-lite/.idea/modules.xml +8 -0
  11. package/dist/node_modules/iconv-lite/.idea/vcs.xml +6 -0
  12. package/dist/node_modules/iconv-lite/LICENSE +21 -0
  13. package/dist/node_modules/iconv-lite/encodings/dbcs-codec.js +597 -0
  14. package/dist/node_modules/iconv-lite/encodings/dbcs-data.js +188 -0
  15. package/dist/node_modules/iconv-lite/encodings/index.js +23 -0
  16. package/dist/node_modules/iconv-lite/encodings/internal.js +198 -0
  17. package/dist/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
  18. package/dist/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
  19. package/dist/node_modules/iconv-lite/encodings/sbcs-data.js +179 -0
  20. package/dist/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
  21. package/dist/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
  22. package/dist/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
  23. package/dist/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
  24. package/dist/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
  25. package/dist/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
  26. package/dist/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
  27. package/dist/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
  28. package/dist/node_modules/iconv-lite/encodings/utf16.js +197 -0
  29. package/dist/node_modules/iconv-lite/encodings/utf32.js +319 -0
  30. package/dist/node_modules/iconv-lite/encodings/utf7.js +290 -0
  31. package/dist/node_modules/iconv-lite/lib/bom-handling.js +52 -0
  32. package/dist/node_modules/iconv-lite/lib/index.d.ts +41 -0
  33. package/dist/node_modules/iconv-lite/lib/index.js +1 -0
  34. package/dist/node_modules/iconv-lite/lib/streams.js +109 -0
  35. package/dist/node_modules/iconv-lite/package.json +1 -0
  36. package/dist/node_modules/mime-match/package.json +1 -1
  37. package/dist/node_modules/mkdirp/package.json +1 -1
  38. package/dist/node_modules/multer-aliyun-oss/index.js +2 -2
  39. package/dist/node_modules/multer-aliyun-oss/package.json +1 -1
  40. package/dist/node_modules/multer-cos/package.json +1 -1
  41. package/dist/node_modules/multer-s3/package.json +1 -1
  42. package/dist/server/FileModel.js +8 -3
  43. package/dist/server/actions/attachments.d.ts +11 -1
  44. package/dist/server/actions/attachments.js +8 -6
  45. package/dist/server/collections/attachments.js +2 -2
  46. package/dist/server/collections/storages.js +1 -1
  47. package/dist/server/index.d.ts +1 -1
  48. package/dist/server/index.js +0 -2
  49. package/dist/server/migrations/20250225225034-increase-url-length.d.ts +14 -0
  50. package/dist/server/migrations/20250225225034-increase-url-length.js +105 -0
  51. package/dist/server/server.d.ts +15 -4
  52. package/dist/server/server.js +29 -29
  53. package/dist/server/storages/ali-oss.d.ts +3 -3
  54. package/dist/server/storages/ali-oss.js +10 -10
  55. package/dist/server/storages/index.d.ts +13 -12
  56. package/dist/server/storages/index.js +8 -1
  57. package/dist/server/storages/local.d.ts +5 -3
  58. package/dist/server/storages/local.js +16 -12
  59. package/dist/server/storages/s3.d.ts +4 -4
  60. package/dist/server/storages/s3.js +21 -21
  61. package/dist/server/storages/tx-cos.d.ts +4 -4
  62. package/dist/server/storages/tx-cos.js +16 -16
  63. package/dist/server/utils.js +5 -4
  64. package/package.json +3 -2
@@ -8,9 +8,7 @@
8
8
  */
9
9
  import { AttachmentModel, StorageType } from '.';
10
10
  export default class extends StorageType {
11
- filenameKey: string;
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
- delete(storage: any, records: AttachmentModel[]): Promise<[number, AttachmentModel[]]>;
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
- filenameKey = "key";
37
- make(storage) {
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
- defaults() {
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(storage);
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
- filenameKey: string;
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
- delete(storage: any, records: AttachmentModel[]): Promise<[number, AttachmentModel[]]>;
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
- filenameKey = "url";
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
- async delete(storage, records) {
63
- const { cos } = this.make(storage);
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)))];
@@ -41,12 +41,13 @@ __export(utils_exports, {
41
41
  getFilename: () => getFilename
42
42
  });
43
43
  module.exports = __toCommonJS(utils_exports);
44
- var import_crypto = __toESM(require("crypto"));
44
+ var import_utils = require("@nocobase/utils");
45
+ var import_iconv_lite = __toESM(require("iconv-lite"));
45
46
  var import_path = __toESM(require("path"));
46
47
  function getFilename(req, file, cb) {
47
- import_crypto.default.pseudoRandomBytes(16, function(err, raw) {
48
- cb(err, err ? void 0 : `${raw.toString("hex")}${import_path.default.extname(file.originalname)}`);
49
- });
48
+ const originalname = import_iconv_lite.default.decode(Buffer.from(file.originalname, "binary"), "utf8");
49
+ const baseName = import_path.default.basename(originalname, import_path.default.extname(originalname));
50
+ cb(null, `${baseName}-${(0, import_utils.uid)(6)}${import_path.default.extname(originalname)}`);
50
51
  }
51
52
  const cloudFilenameGetter = (storage) => (req, file, cb) => {
52
53
  getFilename(req, file, (err, filename) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-file-manager",
3
- "version": "1.6.0-beta.9",
3
+ "version": "1.6.0",
4
4
  "displayName": "File manager",
5
5
  "displayName.zh-CN": "文件管理器",
6
6
  "description": "Provides files storage services with files collection template and attachment field.",
@@ -20,6 +20,7 @@
20
20
  "@types/multer": "^1.4.5",
21
21
  "antd": "5.x",
22
22
  "cos-nodejs-sdk-v5": "^2.11.14",
23
+ "iconv-lite": "^0.6.3",
23
24
  "koa-static": "^5.0.0",
24
25
  "mime-match": "^1.0.2",
25
26
  "mkdirp": "~0.5.4",
@@ -43,5 +44,5 @@
43
44
  "Collections",
44
45
  "Collection fields"
45
46
  ],
46
- "gitHead": "eb1ff948fcf7a51175626a1a56a8b8d9b90be006"
47
+ "gitHead": "7422d72a4e515a11300860028a26030ed5732135"
47
48
  }