@nocobase/plugin-file-manager 1.9.32 → 1.9.34

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 (94) hide show
  1. package/dist/client/index.js +1 -1
  2. package/dist/client/schemas/storageTypes/ali-oss.d.ts +12 -0
  3. package/dist/client/schemas/storageTypes/common.d.ts +12 -0
  4. package/dist/client/schemas/storageTypes/index.d.ts +48 -0
  5. package/dist/client/schemas/storageTypes/local.d.ts +12 -0
  6. package/dist/client/schemas/storageTypes/s3.d.ts +12 -0
  7. package/dist/client/schemas/storageTypes/tx-cos.d.ts +12 -0
  8. package/dist/common/collections/storages.d.ts +11 -0
  9. package/dist/common/collections/storages.js +6 -0
  10. package/dist/externalVersion.js +7 -7
  11. package/dist/locale/de-DE.json +9 -3
  12. package/dist/locale/en-US.json +9 -3
  13. package/dist/locale/es-ES.json +9 -3
  14. package/dist/locale/fr-FR.json +9 -3
  15. package/dist/locale/it-IT.json +9 -3
  16. package/dist/locale/ja-JP.json +9 -3
  17. package/dist/locale/ko-KR.json +9 -3
  18. package/dist/locale/nl-NL.json +9 -3
  19. package/dist/locale/pt-BR.json +9 -3
  20. package/dist/locale/ru-RU.json +9 -3
  21. package/dist/locale/tr-TR.json +9 -3
  22. package/dist/locale/uk-UA.json +9 -3
  23. package/dist/locale/zh-CN.json +10 -4
  24. package/dist/locale/zh-TW.json +13 -7
  25. package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
  26. package/dist/node_modules/@aws-sdk/lib-storage/LICENSE +201 -0
  27. package/dist/node_modules/{multer-s3 → @aws-sdk/lib-storage/dist-cjs}/index.js +574 -6229
  28. package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/runtimeConfig.browser.js +8 -0
  29. package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/runtimeConfig.js +10 -0
  30. package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/runtimeConfig.native.js +8 -0
  31. package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/runtimeConfig.shared.js +6 -0
  32. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/Upload.js +304 -0
  33. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/bytelength.js +27 -0
  34. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/chunker.js +24 -0
  35. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/chunks/getChunkStream.js +24 -0
  36. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/chunks/getChunkUint8Array.js +19 -0
  37. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/chunks/getDataReadable.js +11 -0
  38. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/chunks/getDataReadableStream.js +24 -0
  39. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/index.js +2 -0
  40. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/runtimeConfig.browser.js +5 -0
  41. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/runtimeConfig.js +7 -0
  42. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/runtimeConfig.native.js +5 -0
  43. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/runtimeConfig.shared.js +3 -0
  44. package/dist/node_modules/@aws-sdk/lib-storage/dist-es/types.js +1 -0
  45. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/Upload.d.ts +59 -0
  46. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/bytelength.d.ts +1 -0
  47. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/chunker.d.ts +3 -0
  48. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/chunks/getChunkStream.d.ts +2 -0
  49. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/chunks/getChunkUint8Array.d.ts +2 -0
  50. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/chunks/getDataReadable.d.ts +3 -0
  51. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/chunks/getDataReadableStream.d.ts +1 -0
  52. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/index.d.ts +2 -0
  53. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/runtimeConfig.browser.d.ts +7 -0
  54. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/runtimeConfig.d.ts +8 -0
  55. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/runtimeConfig.native.d.ts +7 -0
  56. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/runtimeConfig.shared.d.ts +6 -0
  57. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/Upload.d.ts +43 -0
  58. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/bytelength.d.ts +1 -0
  59. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/chunker.d.ts +6 -0
  60. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/chunks/getChunkStream.d.ts +6 -0
  61. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/chunks/getChunkUint8Array.d.ts +5 -0
  62. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/chunks/getDataReadable.d.ts +4 -0
  63. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/chunks/getDataReadableStream.d.ts +3 -0
  64. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/index.d.ts +2 -0
  65. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/runtimeConfig.browser.d.ts +4 -0
  66. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/runtimeConfig.d.ts +4 -0
  67. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/runtimeConfig.native.d.ts +4 -0
  68. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/runtimeConfig.shared.d.ts +3 -0
  69. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/types.d.ts +22 -0
  70. package/dist/node_modules/@aws-sdk/lib-storage/dist-types/types.d.ts +51 -0
  71. package/dist/node_modules/@aws-sdk/lib-storage/package.json +1 -0
  72. package/dist/node_modules/ali-oss/package.json +1 -1
  73. package/dist/node_modules/mime-match/package.json +1 -1
  74. package/dist/node_modules/mime-types/package.json +1 -1
  75. package/dist/node_modules/mkdirp/package.json +1 -1
  76. package/dist/node_modules/multer-cos/package.json +1 -1
  77. package/dist/node_modules/url-join/package.json +1 -1
  78. package/dist/server/storages/index.d.ts +1 -0
  79. package/dist/server/storages/local.js +1 -1
  80. package/dist/server/storages/s3.d.ts +10 -3
  81. package/dist/server/storages/s3.js +121 -29
  82. package/dist/server/storages/tx-cos.js +1 -1
  83. package/dist/server/utils.d.ts +1 -0
  84. package/dist/server/utils.js +43 -0
  85. package/package.json +3 -2
  86. package/dist/node_modules/multer-s3/.gitattributes +0 -1
  87. package/dist/node_modules/multer-s3/.travis.yml +0 -6
  88. package/dist/node_modules/multer-s3/LICENSE +0 -22
  89. package/dist/node_modules/multer-s3/package.json +0 -1
  90. package/dist/node_modules/multer-s3/test/basic.js +0 -293
  91. package/dist/node_modules/multer-s3/test/files/a.txt +0 -1
  92. package/dist/node_modules/multer-s3/test/files/test.svg +0 -3
  93. package/dist/node_modules/multer-s3/test/files/test2.svg +0 -9
  94. package/dist/node_modules/multer-s3/test/util/mock-s3.js +0 -17
@@ -0,0 +1,43 @@
1
+ import { CompleteMultipartUploadCommandOutput } from "@aws-sdk/client-s3";
2
+ import { EventEmitter } from "events";
3
+ import { BodyDataTypes, Options, Progress } from "./types";
4
+ export interface RawDataPart {
5
+ partNumber: number;
6
+ data: BodyDataTypes;
7
+ lastPart?: boolean;
8
+ }
9
+ export declare class Upload extends EventEmitter {
10
+ private static MIN_PART_SIZE;
11
+ private MAX_PARTS;
12
+ private readonly queueSize;
13
+ private readonly partSize;
14
+ private readonly leavePartsOnError;
15
+ private readonly tags;
16
+ private readonly client;
17
+ private readonly params;
18
+ private totalBytes?;
19
+ private bytesUploadedSoFar;
20
+ private abortController;
21
+ private concurrentUploaders;
22
+ private createMultiPartPromise?;
23
+ private abortMultipartUploadCommand;
24
+ private uploadedParts;
25
+ private uploadEnqueuedPartsCount;
26
+ uploadId?: string;
27
+ uploadEvent?: string;
28
+ private isMultiPart;
29
+ private singleUploadResult?;
30
+ private sent;
31
+ constructor(options: Options);
32
+ abort(): Promise<void>;
33
+ done(): Promise<CompleteMultipartUploadCommandOutput>;
34
+ on(event: "httpUploadProgress", listener: (progress: Progress) => void): this;
35
+ private __uploadUsingPut;
36
+ private __createMultipartUpload;
37
+ private __doConcurrentUpload;
38
+ private __doMultipartUpload;
39
+ private markUploadAsAborted;
40
+ private __notifyProgress;
41
+ private __abortTimeout;
42
+ private __validateInput;
43
+ }
@@ -0,0 +1 @@
1
+ export declare const byteLength: (input: any) => any;
@@ -0,0 +1,6 @@
1
+ import { BodyDataTypes } from "./types";
2
+ import { RawDataPart } from "./Upload";
3
+ export declare const getChunk: (
4
+ data: BodyDataTypes,
5
+ partSize: number
6
+ ) => AsyncGenerator<RawDataPart, void, undefined>;
@@ -0,0 +1,6 @@
1
+ import { RawDataPart } from "../Upload";
2
+ export declare function getChunkStream<T>(
3
+ data: T,
4
+ partSize: number,
5
+ getNextData: (data: T) => AsyncGenerator<Uint8Array>
6
+ ): AsyncGenerator<RawDataPart, void, undefined>;
@@ -0,0 +1,5 @@
1
+ import { RawDataPart } from "../Upload";
2
+ export declare function getChunkUint8Array(
3
+ data: Uint8Array,
4
+ partSize: number
5
+ ): AsyncGenerator<RawDataPart, void, undefined>;
@@ -0,0 +1,4 @@
1
+ import { Readable } from "stream";
2
+ export declare function getDataReadable(
3
+ data: Readable
4
+ ): AsyncGenerator<Uint8Array>;
@@ -0,0 +1,3 @@
1
+ export declare function getDataReadableStream(
2
+ data: ReadableStream
3
+ ): AsyncGenerator<Uint8Array>;
@@ -0,0 +1,2 @@
1
+ export * from "./Upload";
2
+ export * from "./types";
@@ -0,0 +1,4 @@
1
+ export declare const ClientDefaultValues: {
2
+ runtime: string;
3
+ lstatSync: () => void;
4
+ };
@@ -0,0 +1,4 @@
1
+ export declare const ClientDefaultValues: {
2
+ runtime: string;
3
+ lstatSync: import("fs").StatSyncFn;
4
+ };
@@ -0,0 +1,4 @@
1
+ export declare const ClientDefaultValues: {
2
+ runtime: string;
3
+ lstatSync: () => void;
4
+ };
@@ -0,0 +1,3 @@
1
+ export declare const ClientSharedValues: {
2
+ lstatSync: () => void;
3
+ };
@@ -0,0 +1,22 @@
1
+ import { PutObjectCommandInput, S3Client, Tag } from "@aws-sdk/client-s3";
2
+ import { AbortController } from "@smithy/types";
3
+ export interface Progress {
4
+ loaded?: number;
5
+ total?: number;
6
+ part?: number;
7
+ Key?: string;
8
+ Bucket?: string;
9
+ }
10
+ export type BodyDataTypes = PutObjectCommandInput["Body"];
11
+ export type ServiceClients = S3Client;
12
+ export interface Configuration {
13
+ queueSize: number;
14
+ partSize: number;
15
+ leavePartsOnError: boolean;
16
+ tags: Tag[];
17
+ abortController?: AbortController;
18
+ }
19
+ export interface Options extends Partial<Configuration> {
20
+ params: PutObjectCommandInput;
21
+ client: S3Client;
22
+ }
@@ -0,0 +1,51 @@
1
+ import { PutObjectCommandInput, S3Client, Tag } from "@aws-sdk/client-s3";
2
+ import type { AbortController } from "@smithy/types";
3
+ export interface Progress {
4
+ loaded?: number;
5
+ total?: number;
6
+ part?: number;
7
+ Key?: string;
8
+ Bucket?: string;
9
+ }
10
+ export type BodyDataTypes = PutObjectCommandInput["Body"];
11
+ /**
12
+ * @deprecated redundant, use {@link S3Client} directly.
13
+ */
14
+ export type ServiceClients = S3Client;
15
+ export interface Configuration {
16
+ /**
17
+ * The size of the concurrent queue manager to upload parts in parallel. Set to 1 for synchronous uploading of parts. Note that the uploader will buffer at most queueSize * partSize bytes into memory at any given time.
18
+ * default: 4
19
+ */
20
+ queueSize: number;
21
+ /**
22
+ * Default: 5 mb
23
+ * The size in bytes for each individual part to be uploaded. Adjust the part size to ensure the number of parts does not exceed maxTotalParts. See 5mb is the minimum allowed part size.
24
+ */
25
+ partSize: number;
26
+ /**
27
+ * Default: false
28
+ * Whether to abort the multipart upload if an error occurs. Set to true if you want to handle failures manually. If set to false (default)
29
+ * the upload will drop parts that have failed.
30
+ */
31
+ leavePartsOnError: boolean;
32
+ /**
33
+ * The tags to apply to the object.
34
+ */
35
+ tags: Tag[];
36
+ /**
37
+ * Optional abort controller for controlling this upload's abort signal externally.
38
+ */
39
+ abortController?: AbortController;
40
+ }
41
+ export interface Options extends Partial<Configuration> {
42
+ /**
43
+ * This is the data that is uploaded.
44
+ */
45
+ params: PutObjectCommandInput;
46
+ /**
47
+ * A service client.
48
+ * This the target where we upload data.
49
+ */
50
+ client: S3Client;
51
+ }
@@ -0,0 +1 @@
1
+ {"name":"@aws-sdk/lib-storage","version":"3.750.0","description":"Storage higher order operation","main":"./dist-cjs/index.js","module":"./dist-es/index.js","types":"./dist-types/index.d.ts","scripts":{"build":"concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'","build:cjs":"node ../../scripts/compilation/inline lib-storage","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","test":"yarn g:vitest run","test:e2e":"yarn g:vitest run -c vitest.config.e2e.ts --mode development","test:watch":"yarn g:vitest watch","test:e2e:watch":"yarn g:vitest watch -c vitest.config.e2e.ts"},"engines":{"node":">=18.0.0"},"author":{"name":"AWS SDK for JavaScript Team","url":"https://aws.amazon.com/javascript/"},"license":"Apache-2.0","dependencies":{"@smithy/abort-controller":"^4.0.1","@smithy/middleware-endpoint":"^4.0.5","@smithy/smithy-client":"^4.1.5","buffer":"5.6.0","events":"3.3.0","stream-browserify":"3.0.0","tslib":"^2.6.2"},"peerDependencies":{"@aws-sdk/client-s3":"^3.750.0"},"devDependencies":{"@aws-sdk/client-s3":"3.750.0","@smithy/types":"^4.1.0","@tsconfig/recommended":"1.0.1","@types/node":"^18.19.69","concurrently":"7.0.0","downlevel-dts":"0.10.1","rimraf":"3.0.2","typescript":"~5.2.2","web-streams-polyfill":"3.2.1"},"typesVersions":{"<4.0":{"dist-types/*":["dist-types/ts3.4/*"]}},"browser":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.browser","fs":false,"stream":"stream-browserify"},"react-native":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.native"},"files":["dist-*/**"],"homepage":"https://github.com/aws/aws-sdk-js-v3/tree/main/lib/lib-storage","repository":{"type":"git","url":"https://github.com/aws/aws-sdk-js-v3.git","directory":"lib/lib-storage"},"_lastModified":"2026-01-09T00:54:14.745Z"}
@@ -1 +1 @@
1
- {"name":"ali-oss","version":"6.20.0","description":"aliyun oss(object storage service) node client","main":"./lib/client.js","files":["lib","shims","dist"],"browser":{"./lib/client.js":"./dist/aliyun-oss-sdk.js","mime":"mime/lite","urllib":"./shims/xhr.js","utility":"./shims/utility.js","crypto":"./shims/crypto/crypto.js","debug":"./shims/debug","fs":false,"child_process":false,"is-type-of":"./shims/is-type-of.js"},"scripts":{"build-change-log":"standard-version","test":"npm run tsc && mocha -t 120000 -r should -r dotenv/config test/node/*.test.js test/node/**/*.test.js","test-cov":"npm run tsc && nyc --reporter=lcov node_modules/.bin/_mocha -t 120000 -r should test/node/*.test.js test/node/**/*.test.js","jshint":"jshint .","build-test":"MINIFY=1 node browser-build.js > test/browser/build/aliyun-oss-sdk.min.js && node -r dotenv/config task/browser-test-build.js > test/browser/build/tests.js","browser-test":"npm run build-test && karma start","build-dist":"npm run tsc && node browser-build.js > dist/aliyun-oss-sdk.js && MINIFY=1 node browser-build.js > dist/aliyun-oss-sdk.min.js","publish-to-npm":"node publish-npm-check.js && npm publish","publish-to-cdn":"node publish.js","snyk-protect":"snyk-protect","lint-staged":"lint-staged","detect-secrets":"node task/detect-secrets","tsc":"npm run tsc:clean && npm run tsc:build","tsc:build":"tsc -b tsconfig.json tsconfig-cjs.json","tsc:watch":"tsc -b tsconfig.json tsconfig-cjs.json --watch","tsc:clean":"tsc -b tsconfig.json tsconfig-cjs.json --clean ","prepare":"husky install"},"git-pre-hooks":{"pre-release":"npm run build-dist","post-release":["npm run publish-to-npm","npm run publish-to-cdn"]},"homepage":"https://github.com/ali-sdk/ali-oss","bugs":{"url":"https://github.com/ali-sdk/ali-oss/issues"},"publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"},"repository":{"type":"git","url":"https://github.com/ali-sdk/ali-oss.git"},"keywords":["oss","client","file","aliyun"],"author":"dead_horse","license":"MIT","engines":{"node":">=8"},"devDependencies":{"@babel/core":"^7.11.6","@babel/plugin-transform-regenerator":"^7.10.4","@babel/plugin-transform-runtime":"^7.11.5","@babel/preset-env":"^7.11.5","@babel/runtime":"^7.11.2","@commitlint/cli":"^17.6.7","@commitlint/config-conventional":"^16.2.4","@octokit/core":"^5.0.0","@semantic-release/exec":"^6.0.3","@semantic-release/git":"^10.0.1","@semantic-release/npm":"^10.0.5","@snyk/protect":"^1.1196.0","@types/node":"^14.0.12","@typescript-eslint/eslint-plugin":"^5.0.0","@typescript-eslint/parser":"^5.0.0","aliasify":"^2.0.0","axios":"0.27.2","babelify":"^10.0.0","beautify-benchmark":"^0.2.4","benchmark":"^2.1.1","bluebird":"^3.1.5","browserify":"^17.0.0","core-js":"^3.6.5","crypto-js":"^3.1.9-1","dotenv":"^8.2.0","eslint":"^8.44.0","eslint-config-airbnb":"^19.0.4","eslint-config-ali":"^13.0.0","eslint-config-prettier":"^8.8.0","eslint-plugin-import":"^2.21.1","eslint-plugin-jsx-a11y":"^6.0.3","eslint-plugin-prettier":"^4.2.1","filereader":"^0.10.3","form-data":"^4.0.0","git-pre-hooks":"^1.2.0","husky":"^7.0.4","immediate":"^3.3.0","karma":"^6.3.4","karma-browserify":"^8.1.0","karma-chrome-launcher":"^2.2.0","karma-firefox-launcher":"^1.0.1","karma-ie-launcher":"^1.0.0","karma-mocha":"^2.0.1","karma-safari-launcher":"^1.0.0","lint-staged":"^12.4.1","mm":"^2.0.0","mocha":"^9.1.2","nyc":"^15.1.0","prettier":"^3.0.0","promise-polyfill":"^6.0.2","puppeteer":"19.0.0","semantic-release":"^21.1.1","should":"^11.0.0","sinon":"^15.2.0","standard-version":"^9.3.1","stream-equal":"^1.1.0","timemachine":"^0.3.0","typescript":"^3.9.5","uglify-js":"^3.14.2","watchify":"^4.0.0"},"dependencies":{"address":"^1.2.2","agentkeepalive":"^3.4.1","bowser":"^1.6.0","copy-to":"^2.0.1","dateformat":"^2.0.0","debug":"^4.3.4","destroy":"^1.0.4","end-or-error":"^1.0.1","get-ready":"^1.0.0","humanize-ms":"^1.2.0","is-type-of":"^1.4.0","js-base64":"^2.5.2","jstoxml":"^2.0.0","lodash":"^4.17.21","merge-descriptors":"^1.0.1","mime":"^2.4.5","platform":"^1.3.1","pump":"^3.0.0","qs":"^6.4.0","sdk-base":"^2.0.1","stream-http":"2.8.2","stream-wormhole":"^1.0.4","urllib":"2.41.0","utility":"^1.18.0","xml2js":"^0.6.2"},"snyk":true,"lint-staged":{"**/!(dist)/*":["npm run detect-secrets --"],"**/*.{js,ts}":["eslint --cache --fix --ext .js,.ts","prettier --write","git add"]},"_lastModified":"2025-12-24T08:38:11.587Z"}
1
+ {"name":"ali-oss","version":"6.20.0","description":"aliyun oss(object storage service) node client","main":"./lib/client.js","files":["lib","shims","dist"],"browser":{"./lib/client.js":"./dist/aliyun-oss-sdk.js","mime":"mime/lite","urllib":"./shims/xhr.js","utility":"./shims/utility.js","crypto":"./shims/crypto/crypto.js","debug":"./shims/debug","fs":false,"child_process":false,"is-type-of":"./shims/is-type-of.js"},"scripts":{"build-change-log":"standard-version","test":"npm run tsc && mocha -t 120000 -r should -r dotenv/config test/node/*.test.js test/node/**/*.test.js","test-cov":"npm run tsc && nyc --reporter=lcov node_modules/.bin/_mocha -t 120000 -r should test/node/*.test.js test/node/**/*.test.js","jshint":"jshint .","build-test":"MINIFY=1 node browser-build.js > test/browser/build/aliyun-oss-sdk.min.js && node -r dotenv/config task/browser-test-build.js > test/browser/build/tests.js","browser-test":"npm run build-test && karma start","build-dist":"npm run tsc && node browser-build.js > dist/aliyun-oss-sdk.js && MINIFY=1 node browser-build.js > dist/aliyun-oss-sdk.min.js","publish-to-npm":"node publish-npm-check.js && npm publish","publish-to-cdn":"node publish.js","snyk-protect":"snyk-protect","lint-staged":"lint-staged","detect-secrets":"node task/detect-secrets","tsc":"npm run tsc:clean && npm run tsc:build","tsc:build":"tsc -b tsconfig.json tsconfig-cjs.json","tsc:watch":"tsc -b tsconfig.json tsconfig-cjs.json --watch","tsc:clean":"tsc -b tsconfig.json tsconfig-cjs.json --clean ","prepare":"husky install"},"git-pre-hooks":{"pre-release":"npm run build-dist","post-release":["npm run publish-to-npm","npm run publish-to-cdn"]},"homepage":"https://github.com/ali-sdk/ali-oss","bugs":{"url":"https://github.com/ali-sdk/ali-oss/issues"},"publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"},"repository":{"type":"git","url":"https://github.com/ali-sdk/ali-oss.git"},"keywords":["oss","client","file","aliyun"],"author":"dead_horse","license":"MIT","engines":{"node":">=8"},"devDependencies":{"@babel/core":"^7.11.6","@babel/plugin-transform-regenerator":"^7.10.4","@babel/plugin-transform-runtime":"^7.11.5","@babel/preset-env":"^7.11.5","@babel/runtime":"^7.11.2","@commitlint/cli":"^17.6.7","@commitlint/config-conventional":"^16.2.4","@octokit/core":"^5.0.0","@semantic-release/exec":"^6.0.3","@semantic-release/git":"^10.0.1","@semantic-release/npm":"^10.0.5","@snyk/protect":"^1.1196.0","@types/node":"^14.0.12","@typescript-eslint/eslint-plugin":"^5.0.0","@typescript-eslint/parser":"^5.0.0","aliasify":"^2.0.0","axios":"0.27.2","babelify":"^10.0.0","beautify-benchmark":"^0.2.4","benchmark":"^2.1.1","bluebird":"^3.1.5","browserify":"^17.0.0","core-js":"^3.6.5","crypto-js":"^3.1.9-1","dotenv":"^8.2.0","eslint":"^8.44.0","eslint-config-airbnb":"^19.0.4","eslint-config-ali":"^13.0.0","eslint-config-prettier":"^8.8.0","eslint-plugin-import":"^2.21.1","eslint-plugin-jsx-a11y":"^6.0.3","eslint-plugin-prettier":"^4.2.1","filereader":"^0.10.3","form-data":"^4.0.0","git-pre-hooks":"^1.2.0","husky":"^7.0.4","immediate":"^3.3.0","karma":"^6.3.4","karma-browserify":"^8.1.0","karma-chrome-launcher":"^2.2.0","karma-firefox-launcher":"^1.0.1","karma-ie-launcher":"^1.0.0","karma-mocha":"^2.0.1","karma-safari-launcher":"^1.0.0","lint-staged":"^12.4.1","mm":"^2.0.0","mocha":"^9.1.2","nyc":"^15.1.0","prettier":"^3.0.0","promise-polyfill":"^6.0.2","puppeteer":"19.0.0","semantic-release":"^21.1.1","should":"^11.0.0","sinon":"^15.2.0","standard-version":"^9.3.1","stream-equal":"^1.1.0","timemachine":"^0.3.0","typescript":"^3.9.5","uglify-js":"^3.14.2","watchify":"^4.0.0"},"dependencies":{"address":"^1.2.2","agentkeepalive":"^3.4.1","bowser":"^1.6.0","copy-to":"^2.0.1","dateformat":"^2.0.0","debug":"^4.3.4","destroy":"^1.0.4","end-or-error":"^1.0.1","get-ready":"^1.0.0","humanize-ms":"^1.2.0","is-type-of":"^1.4.0","js-base64":"^2.5.2","jstoxml":"^2.0.0","lodash":"^4.17.21","merge-descriptors":"^1.0.1","mime":"^2.4.5","platform":"^1.3.1","pump":"^3.0.0","qs":"^6.4.0","sdk-base":"^2.0.1","stream-http":"2.8.2","stream-wormhole":"^1.0.4","urllib":"2.41.0","utility":"^1.18.0","xml2js":"^0.6.2"},"snyk":true,"lint-staged":{"**/!(dist)/*":["npm run detect-secrets --"],"**/*.{js,ts}":["eslint --cache --fix --ext .js,.ts","prettier --write","git add"]},"_lastModified":"2026-01-09T00:54:11.980Z"}
@@ -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-12-24T08:38:06.698Z"}
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":"2026-01-09T00:54:07.171Z"}
@@ -1 +1 @@
1
- {"name":"mime-types","description":"The ultimate javascript content-type utility.","version":"3.0.1","contributors":["Douglas Christopher Wilson <doug@somethingdoug.com>","Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)","Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"],"license":"MIT","keywords":["mime","types"],"repository":"jshttp/mime-types","dependencies":{"mime-db":"^1.54.0"},"devDependencies":{"eslint":"8.33.0","eslint-config-standard":"14.1.1","eslint-plugin-import":"2.27.5","eslint-plugin-markdown":"3.0.0","eslint-plugin-node":"11.1.0","eslint-plugin-promise":"6.1.1","eslint-plugin-standard":"4.1.0","mocha":"10.2.0","nyc":"15.1.0"},"files":["HISTORY.md","LICENSE","index.js","mimeScore.js"],"engines":{"node":">= 0.6"},"scripts":{"lint":"eslint .","test":"mocha --reporter spec test/test.js","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"_lastModified":"2025-12-24T08:38:06.984Z"}
1
+ {"name":"mime-types","description":"The ultimate javascript content-type utility.","version":"3.0.1","contributors":["Douglas Christopher Wilson <doug@somethingdoug.com>","Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)","Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"],"license":"MIT","keywords":["mime","types"],"repository":"jshttp/mime-types","dependencies":{"mime-db":"^1.54.0"},"devDependencies":{"eslint":"8.33.0","eslint-config-standard":"14.1.1","eslint-plugin-import":"2.27.5","eslint-plugin-markdown":"3.0.0","eslint-plugin-node":"11.1.0","eslint-plugin-promise":"6.1.1","eslint-plugin-standard":"4.1.0","mocha":"10.2.0","nyc":"15.1.0"},"files":["HISTORY.md","LICENSE","index.js","mimeScore.js"],"engines":{"node":">= 0.6"},"scripts":{"lint":"eslint .","test":"mocha --reporter spec test/test.js","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"_lastModified":"2026-01-09T00:54:07.459Z"}
@@ -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-12-24T08:38:11.671Z"}
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":"2026-01-09T00:54:12.063Z"}
@@ -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-12-24T08:38:18.608Z"}
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":"2026-01-09T00:54:18.371Z"}
@@ -1 +1 @@
1
- {"name":"url-join","version":"4.0.1","description":"Join urls and normalize as in path.join.","main":"lib/url-join.js","scripts":{"test":"mocha --require should"},"repository":{"type":"git","url":"git://github.com/jfromaniello/url-join.git"},"keywords":["url","join"],"author":"José F. Romaniello <jfromaniello@gmail.com> (http://joseoncode.com)","license":"MIT","devDependencies":{"conventional-changelog":"^1.1.10","mocha":"^3.2.0","should":"~1.2.1"},"_lastModified":"2025-12-24T08:38:06.779Z"}
1
+ {"name":"url-join","version":"4.0.1","description":"Join urls and normalize as in path.join.","main":"lib/url-join.js","scripts":{"test":"mocha --require should"},"repository":{"type":"git","url":"git://github.com/jfromaniello/url-join.git"},"keywords":["url","join"],"author":"José F. Romaniello <jfromaniello@gmail.com> (http://joseoncode.com)","license":"MIT","devDependencies":{"conventional-changelog":"^1.1.10","mocha":"^3.2.0","should":"~1.2.1"},"_lastModified":"2026-01-09T00:54:07.252Z"}
@@ -15,6 +15,7 @@ export interface StorageModel {
15
15
  type: string;
16
16
  name: string;
17
17
  baseUrl: string;
18
+ renameMode?: string;
18
19
  options: Record<string, any>;
19
20
  rules?: Record<string, any>;
20
21
  path?: string;
@@ -76,7 +76,7 @@ class local_default extends import__.StorageType {
76
76
  const mkdirp = require("mkdirp");
77
77
  mkdirp(destPath, (err) => cb(err, destPath));
78
78
  },
79
- filename: import_utils2.getFilename
79
+ filename: (0, import_utils2.diskFilenameGetter)(this.storage)
80
80
  });
81
81
  }
82
82
  async delete(records) {
@@ -6,7 +6,8 @@
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 { AttachmentModel, StorageType } from '.';
9
+ import { S3Client } from '@aws-sdk/client-s3';
10
+ import { AttachmentModel, StorageModel, StorageType } from '.';
10
11
  export default class extends StorageType {
11
12
  static defaults(): {
12
13
  title: string;
@@ -21,8 +22,14 @@ export default class extends StorageType {
21
22
  };
22
23
  };
23
24
  static filenameKey: string;
24
- make(): any;
25
- calculateContentMD5(body: any): string;
25
+ client: S3Client;
26
+ constructor(storage: StorageModel);
27
+ make(): {
28
+ s3: S3Client;
29
+ _handleFile(req: any, file: any, cb: any): Promise<void>;
30
+ _removeFile(req: any, file: any, cb: any): void;
31
+ };
32
+ getFileURL(file: AttachmentModel, preview?: boolean): string | Promise<string>;
26
33
  deleteS3Objects(bucketName: string, objects: string[]): Promise<{
27
34
  Deleted: any[];
28
35
  }>;
@@ -40,10 +40,20 @@ __export(s3_exports, {
40
40
  });
41
41
  module.exports = __toCommonJS(s3_exports);
42
42
  var import_client_s3 = require("@aws-sdk/client-s3");
43
- var import_crypto = __toESM(require("crypto"));
43
+ var import_lib_storage = require("@aws-sdk/lib-storage");
44
+ var import_url_join = __toESM(require("url-join"));
45
+ var import_utils = require("@nocobase/utils");
46
+ var import_stream = require("stream");
44
47
  var import__ = require(".");
45
48
  var import_constants = require("../../constants");
46
- var import_utils = require("../utils");
49
+ var import_utils2 = require("../utils");
50
+ class CountingStream extends import_stream.Transform {
51
+ size = 0;
52
+ _transform(chunk, encoding, callback) {
53
+ this.size += chunk.length;
54
+ callback(null, chunk);
55
+ }
56
+ }
47
57
  class s3_default extends import__.StorageType {
48
58
  static defaults() {
49
59
  return {
@@ -60,48 +70,130 @@ class s3_default extends import__.StorageType {
60
70
  };
61
71
  }
62
72
  static filenameKey = "key";
63
- make() {
64
- const multerS3 = require("multer-s3");
65
- const { accessKeyId, secretAccessKey, bucket, acl = "public-read", ...options } = this.storage.options;
66
- if (options.endpoint) {
67
- options.forcePathStyle = true;
68
- } else {
69
- options.endpoint = void 0;
70
- }
71
- const s3 = new import_client_s3.S3Client({
73
+ client;
74
+ constructor(storage) {
75
+ super(storage);
76
+ const { accessKeyId, secretAccessKey, ...options } = this.storage.options;
77
+ const params = {
72
78
  ...options,
73
- credentials: {
79
+ requestChecksumCalculation: "WHEN_REQUIRED"
80
+ };
81
+ if (accessKeyId && secretAccessKey) {
82
+ params.credentials = {
74
83
  accessKeyId,
75
84
  secretAccessKey
76
- }
77
- });
78
- return multerS3({
79
- s3,
80
- bucket,
81
- acl,
82
- contentType(req, file, cb) {
83
- if (file.mimetype) {
84
- cb(null, file.mimetype);
85
+ };
86
+ }
87
+ if (options.endpoint) {
88
+ params.forcePathStyle = true;
89
+ } else {
90
+ params.endpoint = void 0;
91
+ }
92
+ this.client = new import_client_s3.S3Client(params);
93
+ this.client.middlewareStack.remove("flexibleChecksumsMiddleware");
94
+ this.client.middlewareStack.remove("flexibleChecksumsInputMiddleware");
95
+ }
96
+ make() {
97
+ const { bucket, acl = "public-read" } = this.storage.options;
98
+ const keyGetter = (0, import_utils2.cloudFilenameGetter)(this.storage);
99
+ const client = this.client;
100
+ const once = (fn) => {
101
+ let called = false;
102
+ return (...args) => {
103
+ if (called) return;
104
+ called = true;
105
+ fn(...args);
106
+ };
107
+ };
108
+ return {
109
+ s3: client,
110
+ async _handleFile(req, file, cb) {
111
+ const done = once(cb);
112
+ let key;
113
+ try {
114
+ key = await new Promise((resolve, reject) => {
115
+ keyGetter(req, file, (err, value) => {
116
+ if (err) {
117
+ reject(err);
118
+ return;
119
+ }
120
+ resolve(value);
121
+ });
122
+ });
123
+ } catch (error) {
124
+ done(error);
85
125
  return;
86
126
  }
87
- multerS3.AUTO_CONTENT_TYPE(req, file, cb);
127
+ try {
128
+ const contentType = file.mimetype || "application/octet-stream";
129
+ const counter = new CountingStream();
130
+ const uploadStream = file.stream.pipe(counter);
131
+ const upload = new import_lib_storage.Upload({
132
+ client,
133
+ params: {
134
+ Bucket: bucket,
135
+ Key: key,
136
+ ACL: acl,
137
+ Body: uploadStream,
138
+ ContentType: contentType
139
+ },
140
+ queueSize: 1,
141
+ leavePartsOnError: false
142
+ });
143
+ const result = await upload.done();
144
+ done(null, {
145
+ size: counter.size,
146
+ bucket,
147
+ key,
148
+ acl,
149
+ contentType,
150
+ etag: result.ETag,
151
+ versionId: result.VersionId
152
+ });
153
+ } catch (error) {
154
+ done(error);
155
+ }
88
156
  },
89
- key: (0, import_utils.cloudFilenameGetter)(this.storage)
90
- });
157
+ _removeFile(req, file, cb) {
158
+ (async () => {
159
+ try {
160
+ await client.send(
161
+ new import_client_s3.DeleteObjectCommand({
162
+ Bucket: bucket,
163
+ Key: file.key
164
+ })
165
+ );
166
+ cb(null);
167
+ } catch (err) {
168
+ cb(err);
169
+ }
170
+ })();
171
+ }
172
+ };
91
173
  }
92
- calculateContentMD5(body) {
93
- const hash = import_crypto.default.createHash("md5").update(body).digest("base64");
94
- return hash;
174
+ getFileURL(file, preview) {
175
+ if (file.url && (0, import_utils.isURL)(file.url)) {
176
+ return super.getFileURL(file, preview);
177
+ }
178
+ const { bucket, endpoint } = this.storage.options;
179
+ const baseUrlHasBucket = endpoint && this.storage.baseUrl && new RegExp(`/${bucket}/?$`).test(this.storage.baseUrl);
180
+ const keys = [
181
+ this.storage.baseUrl,
182
+ endpoint && !baseUrlHasBucket ? bucket : void 0,
183
+ file.path && encodeURI(file.path),
184
+ (0, import_utils2.ensureUrlEncoded)(file.filename),
185
+ preview && this.storage.options.thumbnailRule
186
+ ].filter(Boolean);
187
+ return (0, import_url_join.default)(keys);
95
188
  }
96
189
  async deleteS3Objects(bucketName, objects) {
97
- const { s3 } = this.make();
98
190
  const Deleted = [];
99
191
  for (const Key of objects) {
100
192
  const deleteCommand = new import_client_s3.DeleteObjectCommand({
101
193
  Bucket: bucketName,
102
194
  Key
103
195
  });
104
- await s3.send(deleteCommand);
196
+ await this.client.send(deleteCommand);
105
197
  Deleted.push({ Key });
106
198
  }
107
199
  return {
@@ -56,7 +56,7 @@ class tx_cos_default extends import__.StorageType {
56
56
  ...this.storage.options,
57
57
  dir: (this.storage.path ?? "").replace(/\/+$/, "")
58
58
  },
59
- filename: import_utils2.getFilename
59
+ filename: (0, import_utils2.diskFilenameGetter)(this.storage)
60
60
  });
61
61
  }
62
62
  async delete(records) {
@@ -8,6 +8,7 @@
8
8
  */
9
9
  export declare function getFilename(req: any, file: any, cb: any): void;
10
10
  export declare const cloudFilenameGetter: (storage: any) => (req: any, file: any, cb: any) => void;
11
+ export declare const diskFilenameGetter: (storage: any) => (req: any, file: any, cb: any) => void;
11
12
  export declare function getFileKey(record: any): any;
12
13
  export declare function ensureUrlEncoded(value: any): any;
13
14
  export declare function encodeURL(url: any): any;
@@ -37,6 +37,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
37
37
  var utils_exports = {};
38
38
  __export(utils_exports, {
39
39
  cloudFilenameGetter: () => cloudFilenameGetter,
40
+ diskFilenameGetter: () => diskFilenameGetter,
40
41
  encodeURL: () => encodeURL,
41
42
  ensureUrlEncoded: () => ensureUrlEncoded,
42
43
  getFileKey: () => getFileKey,
@@ -44,6 +45,7 @@ __export(utils_exports, {
44
45
  });
45
46
  module.exports = __toCommonJS(utils_exports);
46
47
  var import_utils = require("@nocobase/utils");
48
+ var import_crypto = __toESM(require("crypto"));
47
49
  var import_path = __toESM(require("path"));
48
50
  var import_url_join = __toESM(require("url-join"));
49
51
  function getFilename(req, file, cb) {
@@ -51,7 +53,29 @@ function getFilename(req, file, cb) {
51
53
  const baseName = import_path.default.basename(originalname.replace(/[<>?*|:"\\/]/g, "-"), import_path.default.extname(originalname));
52
54
  cb(null, `${baseName}-${(0, import_utils.uid)(6)}${import_path.default.extname(originalname)}`);
53
55
  }
56
+ function getOriginalFilename(file) {
57
+ const originalname = Buffer.from(file.originalname, "binary").toString("utf8");
58
+ const extname = import_path.default.extname(originalname);
59
+ const baseName = import_path.default.basename(originalname.replace(/[<>?*|:"\\/]/g, "-"), extname);
60
+ return `${baseName}${extname}`;
61
+ }
54
62
  const cloudFilenameGetter = (storage) => (req, file, cb) => {
63
+ const renameMode = storage.renameMode;
64
+ if (renameMode === "random") {
65
+ import_crypto.default.pseudoRandomBytes(16, function(err, raw) {
66
+ if (err) {
67
+ return cb(err);
68
+ }
69
+ const filename = `${raw.toString("hex")}${import_path.default.extname(file.originalname)}`;
70
+ cb(null, `${storage.path ? `${storage.path.replace(/\/+$/, "")}/` : ""}${filename}`);
71
+ });
72
+ return;
73
+ }
74
+ if (renameMode === "none") {
75
+ const filename = getOriginalFilename(file);
76
+ cb(null, `${storage.path ? `${storage.path.replace(/\/+$/, "")}/` : ""}${filename}`);
77
+ return;
78
+ }
55
79
  getFilename(req, file, (err, filename) => {
56
80
  if (err) {
57
81
  return cb(err);
@@ -59,6 +83,24 @@ const cloudFilenameGetter = (storage) => (req, file, cb) => {
59
83
  cb(null, `${storage.path ? `${storage.path.replace(/\/+$/, "")}/` : ""}${filename}`);
60
84
  });
61
85
  };
86
+ const diskFilenameGetter = (storage) => (req, file, cb) => {
87
+ const renameMode = storage.renameMode;
88
+ if (renameMode === "random") {
89
+ import_crypto.default.pseudoRandomBytes(16, function(err, raw) {
90
+ if (err) {
91
+ return cb(err);
92
+ }
93
+ const filename = `${raw.toString("hex")}${import_path.default.extname(file.originalname)}`;
94
+ cb(null, filename);
95
+ });
96
+ return;
97
+ }
98
+ if (renameMode === "none") {
99
+ cb(null, getOriginalFilename(file));
100
+ return;
101
+ }
102
+ getFilename(req, file, cb);
103
+ };
62
104
  function getFileKey(record) {
63
105
  return (0, import_url_join.default)(record.path || "", record.filename).replace(/^\//, "");
64
106
  }
@@ -87,6 +129,7 @@ function encodeURL(url) {
87
129
  // Annotate the CommonJS export names for ESM import in node:
88
130
  0 && (module.exports = {
89
131
  cloudFilenameGetter,
132
+ diskFilenameGetter,
90
133
  encodeURL,
91
134
  ensureUrlEncoded,
92
135
  getFileKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-file-manager",
3
- "version": "1.9.32",
3
+ "version": "1.9.34",
4
4
  "displayName": "File manager",
5
5
  "displayName.ru-RU": "Менеджер файлов",
6
6
  "displayName.zh-CN": "文件管理器",
@@ -14,6 +14,7 @@
14
14
  "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/file-manager",
15
15
  "devDependencies": {
16
16
  "@aws-sdk/client-s3": "3.750.0",
17
+ "@aws-sdk/lib-storage": "3.750.0",
17
18
  "@formily/antd-v5": "1.x",
18
19
  "@formily/core": "2.x",
19
20
  "@formily/react": "2.x",
@@ -54,5 +55,5 @@
54
55
  "Collections",
55
56
  "Collection fields"
56
57
  ],
57
- "gitHead": "40b6cf8117d8ae2435fead40d26d12647706f852"
58
+ "gitHead": "8779a68face5b8f159aef726f73695f319ab7659"
58
59
  }
@@ -1 +0,0 @@
1
- *.svg text eol=lf
@@ -1,6 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - '6'
4
- - '4'
5
- - '0.12'
6
- - '0.10'