@nocobase/plugin-file-manager 2.1.0-beta.9 → 2.1.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 (133) hide show
  1. package/client-v2.d.ts +2 -0
  2. package/client-v2.js +1 -0
  3. package/dist/client/867ada653cd02a3e.mjs +6 -0
  4. package/dist/client/876.ca16d7a6e6387862.js +11 -0
  5. package/dist/client/index.d.ts +2 -1
  6. package/dist/client/index.js +1 -1
  7. package/dist/client/locale/index.d.ts +2 -1
  8. package/dist/client/previewer/filePreviewTypes.d.ts +1 -31
  9. package/dist/client/templates/file.d.ts +1 -1
  10. package/dist/client-v2/125.0b8eef1f19b87042.js +10 -0
  11. package/dist/client-v2/229.bd72c2d7aa088310.js +10 -0
  12. package/dist/client-v2/336.1dd1b32466d0c778.js +10 -0
  13. package/dist/client-v2/43.eb45d53ba3e9828b.js +10 -0
  14. package/dist/client-v2/450.30cc3ed6973d8c4d.js +10 -0
  15. package/dist/client-v2/867ada653cd02a3e.mjs +6 -0
  16. package/dist/client-v2/876.22cd8e41ac8631ed.js +11 -0
  17. package/dist/client-v2/929.d7e783304cc1f236.js +10 -0
  18. package/dist/client-v2/942.f36d807d763a1b53.js +10 -0
  19. package/dist/{client/StorageOptions.d.ts → client-v2/components/BaseUrlField.d.ts} +1 -1
  20. package/dist/client-v2/components/DefaultField.d.ts +18 -0
  21. package/dist/client-v2/components/FileSizeField.d.ts +10 -0
  22. package/dist/client-v2/components/MimetypeField.d.ts +10 -0
  23. package/dist/client-v2/components/NameField.d.ts +10 -0
  24. package/dist/client-v2/components/ParanoidField.d.ts +10 -0
  25. package/dist/client-v2/components/PathField.d.ts +18 -0
  26. package/dist/client-v2/components/RenameModeField.d.ts +10 -0
  27. package/dist/client-v2/components/TitleField.d.ts +10 -0
  28. package/dist/client-v2/components/index.d.ts +17 -0
  29. package/dist/client-v2/index.d.ts +17 -0
  30. package/dist/client-v2/index.js +10 -0
  31. package/dist/client-v2/locale.d.ts +10 -0
  32. package/dist/{client → client-v2}/models/DisplayPreviewFieldModel.d.ts +1 -1
  33. package/dist/{client → client-v2}/models/UploadActionModel.d.ts +4 -3
  34. package/dist/{client → client-v2}/models/UploadFieldModel.d.ts +1 -1
  35. package/dist/client-v2/models/index.d.ts +11 -0
  36. package/dist/{client → client-v2}/models/uploadFieldUtils.d.ts +8 -0
  37. package/dist/client-v2/pages/FileStoragePage.d.ts +10 -0
  38. package/dist/client-v2/plugin.d.ts +89 -0
  39. package/dist/client-v2/previewer/filePreviewTypes.d.ts +46 -0
  40. package/dist/client-v2/storage-forms/AliOssStorageForm.d.ts +10 -0
  41. package/dist/client-v2/storage-forms/LocalStorageForm.d.ts +10 -0
  42. package/dist/client-v2/storage-forms/S3StorageForm.d.ts +10 -0
  43. package/dist/client-v2/storage-forms/TxCosStorageForm.d.ts +10 -0
  44. package/dist/common/collections/attachments.d.ts +1 -0
  45. package/dist/common/collections/attachments.js +1 -0
  46. package/dist/common/collections/storages.d.ts +1 -0
  47. package/dist/common/collections/storages.js +1 -0
  48. package/dist/externalVersion.js +12 -12
  49. package/dist/locale/de-DE.json +3 -0
  50. package/dist/locale/en-US.json +4 -0
  51. package/dist/locale/es-ES.json +3 -0
  52. package/dist/locale/fr-FR.json +3 -0
  53. package/dist/locale/hu-HU.json +4 -1
  54. package/dist/locale/id-ID.json +4 -1
  55. package/dist/locale/it-IT.json +3 -0
  56. package/dist/locale/ja-JP.json +3 -0
  57. package/dist/locale/ko-KR.json +3 -0
  58. package/dist/locale/nl-NL.json +3 -0
  59. package/dist/locale/pt-BR.json +3 -0
  60. package/dist/locale/ru-RU.json +3 -0
  61. package/dist/locale/tr-TR.json +3 -0
  62. package/dist/locale/uk-UA.json +3 -0
  63. package/dist/locale/vi-VN.json +4 -1
  64. package/dist/locale/zh-CN.json +4 -0
  65. package/dist/locale/zh-TW.json +3 -0
  66. package/dist/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +190 -190
  67. package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
  68. package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/index.js +195 -195
  69. package/dist/node_modules/@aws-sdk/lib-storage/node_modules/buffer/index.d.ts +186 -0
  70. package/dist/node_modules/@aws-sdk/lib-storage/node_modules/buffer/index.js +1794 -0
  71. package/dist/node_modules/@aws-sdk/lib-storage/node_modules/buffer/package.json +82 -0
  72. package/dist/node_modules/@aws-sdk/lib-storage/package.json +1 -1
  73. package/dist/node_modules/ali-oss/lib/client.js +14 -14
  74. package/dist/node_modules/ali-oss/package.json +1 -1
  75. package/dist/node_modules/cos-nodejs-sdk-v5/.github/workflows/auto-changelog.yml +55 -0
  76. package/dist/node_modules/cos-nodejs-sdk-v5/.prettierrc +10 -0
  77. package/dist/node_modules/cos-nodejs-sdk-v5/.travis.yml +16 -0
  78. package/dist/node_modules/cos-nodejs-sdk-v5/LICENSE +21 -0
  79. package/dist/node_modules/cos-nodejs-sdk-v5/demo/crc64.js +9 -0
  80. package/dist/node_modules/cos-nodejs-sdk-v5/demo/demo-sts-scope.js +75 -0
  81. package/dist/node_modules/cos-nodejs-sdk-v5/demo/demo-sts.js +65 -0
  82. package/dist/node_modules/cos-nodejs-sdk-v5/demo/demo.js +4542 -0
  83. package/dist/node_modules/cos-nodejs-sdk-v5/demo/util.js +135 -0
  84. package/dist/node_modules/cos-nodejs-sdk-v5/index.d.ts +2610 -0
  85. package/dist/node_modules/cos-nodejs-sdk-v5/index.js +220 -0
  86. package/dist/node_modules/cos-nodejs-sdk-v5/package.json +1 -0
  87. package/dist/node_modules/cos-nodejs-sdk-v5/sdk/advance.js +1659 -0
  88. package/dist/node_modules/cos-nodejs-sdk-v5/sdk/async.js +59 -0
  89. package/dist/node_modules/cos-nodejs-sdk-v5/sdk/base.js +4404 -0
  90. package/dist/node_modules/cos-nodejs-sdk-v5/sdk/cos.js +137 -0
  91. package/dist/node_modules/cos-nodejs-sdk-v5/sdk/event.js +34 -0
  92. package/dist/node_modules/cos-nodejs-sdk-v5/sdk/select-stream.js +181 -0
  93. package/dist/node_modules/cos-nodejs-sdk-v5/sdk/session.js +126 -0
  94. package/dist/node_modules/cos-nodejs-sdk-v5/sdk/task.js +255 -0
  95. package/dist/node_modules/cos-nodejs-sdk-v5/sdk/util.js +776 -0
  96. package/dist/node_modules/cos-nodejs-sdk-v5/test/csp.js +1302 -0
  97. package/dist/node_modules/cos-nodejs-sdk-v5/test/test.js +6119 -0
  98. package/dist/node_modules/mime-match/index.js +1 -1
  99. package/dist/node_modules/mime-match/package.json +1 -1
  100. package/dist/node_modules/mime-types/index.js +3 -3
  101. package/dist/node_modules/mime-types/package.json +1 -1
  102. package/dist/node_modules/mkdirp/index.js +1 -1
  103. package/dist/node_modules/mkdirp/package.json +1 -1
  104. package/dist/node_modules/url-join/lib/url-join.js +1 -1
  105. package/dist/node_modules/url-join/package.json +1 -1
  106. package/dist/server/actions/attachments.js +2 -2
  107. package/dist/server/actions/index.js +8 -1
  108. package/dist/server/actions/storage-validation.d.ts +10 -0
  109. package/dist/server/actions/storage-validation.js +73 -0
  110. package/dist/server/commands/repair-filenames.d.ts +55 -0
  111. package/dist/server/commands/repair-filenames.js +283 -0
  112. package/dist/server/index.d.ts +1 -1
  113. package/dist/server/index.js +2 -0
  114. package/dist/server/server.d.ts +5 -2
  115. package/dist/server/server.js +19 -7
  116. package/dist/server/storages/ali-oss.d.ts +3 -1
  117. package/dist/server/storages/ali-oss.js +23 -2
  118. package/dist/server/storages/index.d.ts +7 -1
  119. package/dist/server/storages/index.js +8 -1
  120. package/dist/server/storages/local.d.ts +6 -0
  121. package/dist/server/storages/local.js +76 -11
  122. package/dist/server/storages/s3.d.ts +2 -0
  123. package/dist/server/storages/s3.js +26 -0
  124. package/dist/server/storages/tx-cos.d.ts +18 -1
  125. package/dist/server/storages/tx-cos.js +138 -10
  126. package/dist/server/utils.d.ts +3 -0
  127. package/dist/server/utils.js +72 -4
  128. package/package.json +8 -3
  129. package/dist/node_modules/multer-cos/LICENSE +0 -24
  130. package/dist/node_modules/multer-cos/demo/index.js +0 -39
  131. package/dist/node_modules/multer-cos/demo/myMulter.js +0 -88
  132. package/dist/node_modules/multer-cos/index.js +0 -220
  133. package/dist/node_modules/multer-cos/package.json +0 -1
@@ -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":"2026-03-12T13:29:46.758Z"}
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-06-10T23:42:04.081Z"}
@@ -0,0 +1,55 @@
1
+ name: ChangeLog
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ release:
6
+ types: [published]
7
+
8
+ jobs:
9
+ build:
10
+
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/setup-node@v2-beta
15
+ with:
16
+ node-version: '12'
17
+ - uses: actions/checkout@v2
18
+ with:
19
+ fetch-depth: 0
20
+
21
+ - name: Checkout Tool
22
+ uses: actions/checkout@v2
23
+ with:
24
+ repository: konakonall/auto-changelog
25
+ path: 'auto-changelog'
26
+ - name: Build Tool
27
+ run: |
28
+ cd auto-changelog
29
+ npm install
30
+ npm link
31
+
32
+ - name: Generate ChangeLog
33
+ env: # Or as an environment variable
34
+ TOKEN: ${{ secrets.GITHUB_TOKEN }}
35
+ run: |
36
+ auto-changelog --token $TOKEN
37
+ - name: Cat ChangeLog
38
+ run: cat CHANGELOG.md
39
+
40
+ - name: Commit files
41
+ env:
42
+ CI_USER: "gouki0123"
43
+ CI_EMAIL: "gouki0123@gmail.com"
44
+ run: |
45
+ git config --local user.email "$CI_EMAIL"
46
+ git config --local user.name "$CI_USER"
47
+ git add CHANGELOG.md && git commit -m 'Updated CHANGELOG.md' && echo "push=1" >> $GITHUB_ENV || echo "No changes to CHANGELOG.md"
48
+
49
+ - name: Push changes
50
+ if: env.push == 1
51
+ env:
52
+ CI_USER: "gouki0123"
53
+ CI_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54
+ run: |
55
+ git push "https://$CI_USER:$CI_TOKEN@github.com/$GITHUB_REPOSITORY.git" HEAD:master
@@ -0,0 +1,10 @@
1
+ {
2
+ "printWidth": 120,
3
+ "tabWidth": 2,
4
+ "useTabs": false,
5
+ "semi": true,
6
+ "singleQuote": true,
7
+ "jsxSingleQuote": true,
8
+ "jsxBracketSameLine": true,
9
+ "trailingComma": "es5"
10
+ }
@@ -0,0 +1,16 @@
1
+ language: node_js
2
+
3
+ node_js:
4
+ - '8'
5
+
6
+ install:
7
+ - npm install
8
+
9
+ script:
10
+ - npm test
11
+
12
+ notifications:
13
+ email:
14
+ recipients:
15
+ - wjielai@tencent.com
16
+ - fysntian@tencent.com
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017-present 腾讯云
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,9 @@
1
+ var crc64 = require("crc64-ecma182.js");
2
+ var path = require('path');
3
+
4
+ var hash = crc64.crc64(Buffer.from("hello!"));
5
+ console.log('string crc64:', hash);
6
+
7
+ crc64.crc64File(path.join(__dirname, "./demo.js"), function(err, hash) {
8
+ console.log('file crc64:', err || hash);
9
+ });
@@ -0,0 +1,75 @@
1
+ /**
2
+ * 使用临时密钥例子
3
+ */
4
+ var STS = require('qcloud-cos-sts');
5
+ var COS = require('../index');
6
+ var config = require('./config');
7
+
8
+ var allowPrefix = '';
9
+ // 简单上传和分片,需要以下的权限,其他权限列表请看 https://cloud.tencent.com/document/product/436/14048
10
+ var allowActions = [
11
+ 'name/cos:PutObject',
12
+ 'name/cos:InitiateMultipartUpload',
13
+ 'name/cos:ListMultipartUploads',
14
+ 'name/cos:ListParts',
15
+ 'name/cos:UploadPart',
16
+ 'name/cos:CompleteMultipartUpload'
17
+ ];
18
+
19
+
20
+ // 判断是否允许获取密钥
21
+ var allowScope = function (scope) {
22
+ var allow = (scope || []).every(function (item) {
23
+ return allowActions.includes(item.action) &&
24
+ item.bucket === config.bucket &&
25
+ item.region === config.region &&
26
+ (item.prefix || '').startsWith(allowPrefix);
27
+ });
28
+ return allow;
29
+ };
30
+
31
+ var cos = new COS({
32
+ getAuthorization: function (options, callback) {
33
+
34
+ // TODO 这里根据自己业务需要做好放行判断
35
+ if (!allowScope()) {
36
+ console.log('deny Scope');
37
+ return;
38
+ }
39
+
40
+ // 获取临时密钥
41
+ var policy = STS.getPolicy(options.Scope);
42
+ STS.getCredential({
43
+ secretId: config.SecretId,
44
+ secretKey: config.SecretKey,
45
+ policy: policy,
46
+ // durationSeconds: 1800,
47
+ proxy: '',
48
+ region: 'ap-guangzhou'
49
+ }, function (err, data) {
50
+ if (err) {
51
+ console.error(err);
52
+ } else {
53
+ console.log(data);
54
+ var credentials = data.credentials;
55
+ callback({
56
+ TmpSecretId: credentials.tmpSecretId,
57
+ TmpSecretKey: credentials.tmpSecretKey,
58
+ SecurityToken: credentials.sessionToken,
59
+ ExpiredTime: data.expiredTime,
60
+ ScopeLimit: true, // 设为 true 可限制密钥只在相同请求可重用,默认不限制一直可重用,细粒度控制权限需要设为 true
61
+ });
62
+ }
63
+ });
64
+
65
+ },
66
+ });
67
+
68
+ cos.putObject({
69
+ Bucket: config.Bucket,
70
+ Region: config.Region,
71
+ Key: 'dir/1.txt',
72
+ Body: 'hello!',
73
+ }, function (err, data) {
74
+ console.log(err || data);
75
+ });
@@ -0,0 +1,65 @@
1
+ /**
2
+ * 使用临时密钥例子
3
+ */
4
+ var STS = require('qcloud-cos-sts');
5
+ var COS = require('../index');
6
+ var config = require('./config');
7
+
8
+
9
+ var AppId = config.Bucket.substr(config.Bucket.lastIndexOf('-') + 1);
10
+ var policy = {
11
+ 'version': '2.0',
12
+ 'statement': [{
13
+ 'action': [
14
+ // 所有 action 请看文档 https://cloud.tencent.com/document/product/436/31923
15
+ // 简单上传
16
+ 'name/cos:PutObject',
17
+ 'name/cos:PostObject',
18
+ // 分片上传
19
+ 'name/cos:InitiateMultipartUpload',
20
+ 'name/cos:ListMultipartUploads',
21
+ 'name/cos:ListParts',
22
+ 'name/cos:UploadPart',
23
+ 'name/cos:CompleteMultipartUpload'
24
+ ],
25
+ 'effect': 'allow',
26
+ 'principal': {'qcs': ['*']},
27
+ 'resource': [
28
+ 'qcs::cos:' + config.Region + ':uid/' + AppId + ':' + config.Bucket + '/*'
29
+ ]
30
+ }]
31
+ };
32
+
33
+ var cos = new COS({
34
+ getAuthorization: function (options, callback) {
35
+ STS.getCredential({
36
+ secretId: config.SecretId,
37
+ secretKey: config.SecretKey,
38
+ policy: policy,
39
+ durationSeconds: 7200,
40
+ proxy: '',
41
+ region: 'ap-guangzhou'
42
+ }, function (err, data) {
43
+ if (err) {
44
+ console.error(err);
45
+ } else {
46
+ var credentials = data.credentials;
47
+ callback({
48
+ TmpSecretId: credentials.tmpSecretId,
49
+ TmpSecretKey: credentials.tmpSecretKey,
50
+ SecurityToken: credentials.sessionToken,
51
+ ExpiredTime: data.expiredTime,
52
+ });
53
+ }
54
+ });
55
+ },
56
+ });
57
+
58
+ cos.putObject({
59
+ Bucket: config.Bucket,
60
+ Region: config.Region,
61
+ Key: 'dir/1.txt',
62
+ Body: 'hello!',
63
+ }, function (err, data) {
64
+ console.log(err || data);
65
+ });