@nocobase/plugin-file-manager 2.0.0-alpha.9 → 2.0.0-beta.2
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 +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/models/DisplayPreviewFieldModel.d.ts +1 -0
- package/dist/client/models/UploadActionModel.d.ts +3 -1
- package/dist/client/schemas/storageTypes/ali-oss.d.ts +12 -0
- package/dist/client/schemas/storageTypes/common.d.ts +12 -0
- package/dist/client/schemas/storageTypes/index.d.ts +48 -0
- package/dist/client/schemas/storageTypes/local.d.ts +12 -0
- package/dist/client/schemas/storageTypes/s3.d.ts +12 -0
- package/dist/client/schemas/storageTypes/tx-cos.d.ts +12 -0
- package/dist/client/templates/file.d.ts +4 -0
- package/dist/common/collections/storages.d.ts +11 -0
- package/dist/common/collections/storages.js +6 -0
- package/dist/externalVersion.js +8 -8
- package/dist/locale/de-DE.json +42 -29
- package/dist/locale/en-US.json +43 -30
- package/dist/locale/es-ES.json +54 -0
- package/dist/locale/fr-FR.json +45 -12
- package/dist/locale/hu-HU.json +48 -0
- package/dist/locale/id-ID.json +48 -0
- package/dist/locale/it-IT.json +43 -28
- package/dist/locale/ja-JP.json +43 -30
- package/dist/locale/ko-KR.json +46 -24
- package/dist/locale/nl-NL.json +53 -39
- package/dist/locale/pt-BR.json +54 -0
- package/dist/locale/ru-RU.json +47 -11
- package/dist/locale/tr-TR.json +47 -10
- package/dist/locale/uk-UA.json +54 -0
- package/dist/locale/vi-VN.json +48 -0
- package/dist/locale/zh-CN.json +41 -31
- package/dist/locale/zh-TW.json +54 -0
- package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
- package/dist/node_modules/@aws-sdk/lib-storage/LICENSE +201 -0
- package/dist/node_modules/{multer-s3 → @aws-sdk/lib-storage/dist-cjs}/index.js +574 -6229
- package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/runtimeConfig.browser.js +8 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/runtimeConfig.js +10 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/runtimeConfig.native.js +8 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-cjs/runtimeConfig.shared.js +6 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-es/Upload.js +304 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-es/bytelength.js +27 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-es/chunker.js +24 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-es/chunks/getChunkStream.js +24 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-es/chunks/getChunkUint8Array.js +19 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-es/chunks/getDataReadable.js +11 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-es/chunks/getDataReadableStream.js +24 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-es/index.js +2 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-es/runtimeConfig.browser.js +5 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-es/runtimeConfig.js +7 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-es/runtimeConfig.native.js +5 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-es/runtimeConfig.shared.js +3 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-es/types.js +1 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/Upload.d.ts +59 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/bytelength.d.ts +1 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/chunker.d.ts +3 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/chunks/getChunkStream.d.ts +2 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/chunks/getChunkUint8Array.d.ts +2 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/chunks/getDataReadable.d.ts +3 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/chunks/getDataReadableStream.d.ts +1 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/index.d.ts +2 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/runtimeConfig.browser.d.ts +7 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/runtimeConfig.d.ts +8 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/runtimeConfig.native.d.ts +7 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/runtimeConfig.shared.d.ts +6 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/Upload.d.ts +43 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/bytelength.d.ts +1 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/chunker.d.ts +6 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/chunks/getChunkStream.d.ts +6 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/chunks/getChunkUint8Array.d.ts +5 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/chunks/getDataReadable.d.ts +4 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/chunks/getDataReadableStream.d.ts +3 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/index.d.ts +2 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/runtimeConfig.browser.d.ts +4 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/runtimeConfig.d.ts +4 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/runtimeConfig.native.d.ts +4 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/runtimeConfig.shared.d.ts +3 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/ts3.4/types.d.ts +22 -0
- package/dist/node_modules/@aws-sdk/lib-storage/dist-types/types.d.ts +51 -0
- package/dist/node_modules/@aws-sdk/lib-storage/package.json +1 -0
- package/dist/node_modules/{multer-s3 → ali-oss}/LICENSE +1 -2
- package/dist/node_modules/ali-oss/dist/aliyun-oss-sdk.js +44018 -0
- package/dist/node_modules/ali-oss/dist/aliyun-oss-sdk.min.js +4 -0
- package/dist/node_modules/ali-oss/lib/browser/bucket.js +296 -0
- package/dist/node_modules/ali-oss/lib/browser/client.js +452 -0
- package/dist/node_modules/ali-oss/lib/browser/managed-upload.js +360 -0
- package/dist/node_modules/ali-oss/lib/browser/object.js +385 -0
- package/dist/node_modules/ali-oss/lib/browser/version.js +1 -0
- package/dist/node_modules/ali-oss/lib/browser.js +6 -0
- package/dist/node_modules/ali-oss/lib/bucket.js +337 -0
- package/dist/node_modules/{multer-aliyun-oss/index.js → ali-oss/lib/client.js} +2 -2
- package/dist/node_modules/ali-oss/lib/cluster.js +228 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/abortBucketWorm.d.ts +4 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/abortBucketWorm.js +14 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/abortBucketWorm.ts +12 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/completeBucketWorm.d.ts +4 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/completeBucketWorm.js +14 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/completeBucketWorm.ts +12 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketEncryption.js +20 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketInventory.d.ts +10 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketInventory.js +22 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketInventory.ts +21 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketLifecycle.js +13 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketPolicy.js +21 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketTags.js +21 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/deleteBucketWebsite.js +13 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/extendBucketWorm.d.ts +4 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/extendBucketWorm.js +23 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/extendBucketWorm.ts +21 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketEncryption.js +21 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketInventory.d.ts +11 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketInventory.js +25 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketInventory.ts +24 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketLifecycle.js +33 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketPolicy.js +28 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketRequestPayment.js +25 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketStat.d.ts +23 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketStat.js +17 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketStat.ts +34 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketTags.js +23 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketVersioning.js +22 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketWebsite.js +28 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketWorm.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketWorm.js +20 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/getBucketWorm.ts +22 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/index.js +34 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/initiateBucketWorm.d.ts +5 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/initiateBucketWorm.js +24 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/initiateBucketWorm.ts +23 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/listBucketInventory.d.ts +13 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/listBucketInventory.js +29 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/listBucketInventory.ts +32 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/putBucket.js +31 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/putBucketEncryption.js +36 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/putBucketInventory.d.ts +36 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/putBucketInventory.js +58 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/putBucketInventory.ts +84 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/putBucketLifecycle.js +127 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/putBucketPolicy.js +27 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/putBucketRequestPayment.js +40 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/putBucketTags.js +39 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/putBucketVersioning.js +35 -0
- package/dist/node_modules/ali-oss/lib/common/bucket/putBucketWebsite.js +50 -0
- package/dist/node_modules/ali-oss/lib/common/callback.js +27 -0
- package/dist/node_modules/ali-oss/lib/common/client/getReqUrl.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/client/getReqUrl.js +52 -0
- package/dist/node_modules/ali-oss/lib/common/client/getReqUrl.ts +51 -0
- package/dist/node_modules/ali-oss/lib/common/client/initOptions.js +72 -0
- package/dist/node_modules/ali-oss/lib/common/image/index.js +5 -0
- package/dist/node_modules/ali-oss/lib/common/image/processObjectSave.js +45 -0
- package/dist/node_modules/ali-oss/lib/common/multipart-copy.js +240 -0
- package/dist/node_modules/ali-oss/lib/common/multipart.js +271 -0
- package/dist/node_modules/ali-oss/lib/common/object/asyncSignatureUrl.js +57 -0
- package/dist/node_modules/ali-oss/lib/common/object/calculatePostSignature.js +35 -0
- package/dist/node_modules/ali-oss/lib/common/object/copyObject.js +74 -0
- package/dist/node_modules/ali-oss/lib/common/object/delete.js +22 -0
- package/dist/node_modules/ali-oss/lib/common/object/deleteMulti.js +57 -0
- package/dist/node_modules/ali-oss/lib/common/object/deleteObjectTagging.js +22 -0
- package/dist/node_modules/ali-oss/lib/common/object/generateObjectUrl.js +28 -0
- package/dist/node_modules/ali-oss/lib/common/object/get.js +64 -0
- package/dist/node_modules/ali-oss/lib/common/object/getACL.js +30 -0
- package/dist/node_modules/ali-oss/lib/common/object/getAsyncFetch.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/object/getAsyncFetch.js +26 -0
- package/dist/node_modules/ali-oss/lib/common/object/getAsyncFetch.ts +25 -0
- package/dist/node_modules/ali-oss/lib/common/object/getBucketVersions.js +98 -0
- package/dist/node_modules/ali-oss/lib/common/object/getObjectMeta.js +23 -0
- package/dist/node_modules/ali-oss/lib/common/object/getObjectTagging.js +34 -0
- package/dist/node_modules/ali-oss/lib/common/object/getObjectUrl.js +21 -0
- package/dist/node_modules/ali-oss/lib/common/object/getSymlink.js +23 -0
- package/dist/node_modules/ali-oss/lib/common/object/head.js +40 -0
- package/dist/node_modules/ali-oss/lib/common/object/index.js +26 -0
- package/dist/node_modules/ali-oss/lib/common/object/postAsyncFetch.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/object/postAsyncFetch.js +44 -0
- package/dist/node_modules/ali-oss/lib/common/object/postAsyncFetch.ts +46 -0
- package/dist/node_modules/ali-oss/lib/common/object/putACL.js +27 -0
- package/dist/node_modules/ali-oss/lib/common/object/putObjectTagging.js +43 -0
- package/dist/node_modules/ali-oss/lib/common/object/putSymlink.js +33 -0
- package/dist/node_modules/ali-oss/lib/common/object/signatureUrl.js +52 -0
- package/dist/node_modules/ali-oss/lib/common/object/signatureUrlV4.js +70 -0
- package/dist/node_modules/ali-oss/lib/common/parallel.js +177 -0
- package/dist/node_modules/ali-oss/lib/common/signUtils.js +355 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkBucketName.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkBucketName.js +9 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkBucketName.ts +6 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkBucketNameTest.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkBucketNameTest.js +14 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkBucketNameTest.ts +12 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkBucketTag.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkBucketTag.js +49 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkBucketTag.ts +52 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkConfigValid.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkConfigValid.js +30 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkConfigValid.ts +27 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkEnv.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkEnv.js +9 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkEnv.ts +5 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkObjectTag.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkObjectTag.js +50 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkObjectTag.ts +53 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkUserAgent.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkUserAgent.js +7 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkUserAgent.ts +4 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkValid.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkValid.js +14 -0
- package/dist/node_modules/ali-oss/lib/common/utils/checkValid.ts +9 -0
- package/dist/node_modules/ali-oss/lib/common/utils/createRequest.d.ts +8 -0
- package/dist/node_modules/ali-oss/lib/common/utils/createRequest.js +139 -0
- package/dist/node_modules/ali-oss/lib/common/utils/createRequest.ts +169 -0
- package/dist/node_modules/ali-oss/lib/common/utils/dataFix.d.ts +12 -0
- package/dist/node_modules/ali-oss/lib/common/utils/dataFix.js +63 -0
- package/dist/node_modules/ali-oss/lib/common/utils/dataFix.ts +78 -0
- package/dist/node_modules/ali-oss/lib/common/utils/deepCopy.d.ts +2 -0
- package/dist/node_modules/ali-oss/lib/common/utils/deepCopy.js +41 -0
- package/dist/node_modules/ali-oss/lib/common/utils/deepCopy.ts +47 -0
- package/dist/node_modules/ali-oss/lib/common/utils/encodeString.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/encodeString.js +12 -0
- package/dist/node_modules/ali-oss/lib/common/utils/encodeString.ts +7 -0
- package/dist/node_modules/ali-oss/lib/common/utils/encoder.d.ts +2 -0
- package/dist/node_modules/ali-oss/lib/common/utils/encoder.js +9 -0
- package/dist/node_modules/ali-oss/lib/common/utils/encoder.ts +6 -0
- package/dist/node_modules/ali-oss/lib/common/utils/formatInventoryConfig.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/formatInventoryConfig.js +45 -0
- package/dist/node_modules/ali-oss/lib/common/utils/formatInventoryConfig.ts +41 -0
- package/dist/node_modules/ali-oss/lib/common/utils/formatObjKey.d.ts +6 -0
- package/dist/node_modules/ali-oss/lib/common/utils/formatObjKey.js +34 -0
- package/dist/node_modules/ali-oss/lib/common/utils/formatObjKey.ts +35 -0
- package/dist/node_modules/ali-oss/lib/common/utils/formatTag.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/formatTag.js +22 -0
- package/dist/node_modules/ali-oss/lib/common/utils/formatTag.ts +20 -0
- package/dist/node_modules/ali-oss/lib/common/utils/getStandardRegion.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/getStandardRegion.js +7 -0
- package/dist/node_modules/ali-oss/lib/common/utils/getStandardRegion.ts +3 -0
- package/dist/node_modules/ali-oss/lib/common/utils/getStrBytesCount.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/getStrBytesCount.js +17 -0
- package/dist/node_modules/ali-oss/lib/common/utils/getStrBytesCount.ts +12 -0
- package/dist/node_modules/ali-oss/lib/common/utils/getUserAgent.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/getUserAgent.js +18 -0
- package/dist/node_modules/ali-oss/lib/common/utils/getUserAgent.ts +14 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isArray.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isArray.js +6 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isArray.ts +3 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isBlob.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isBlob.js +7 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isBlob.ts +3 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isBuffer.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isBuffer.js +7 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isBuffer.ts +3 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isDingTalk.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isDingTalk.js +10 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isDingTalk.ts +6 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isFile.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isFile.js +6 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isFile.ts +3 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isFunction.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isFunction.js +6 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isFunction.ts +3 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isIP.d.ts +6 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isIP.js +14 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isIP.ts +12 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isObject.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isObject.js +6 -0
- package/dist/node_modules/ali-oss/lib/common/utils/isObject.ts +3 -0
- package/dist/node_modules/ali-oss/lib/common/utils/lowercaseKeyHeader.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/lowercaseKeyHeader.js +14 -0
- package/dist/node_modules/ali-oss/lib/common/utils/lowercaseKeyHeader.ts +11 -0
- package/dist/node_modules/ali-oss/lib/common/utils/obj2xml.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/obj2xml.js +43 -0
- package/dist/node_modules/ali-oss/lib/common/utils/obj2xml.ts +37 -0
- package/dist/node_modules/ali-oss/lib/common/utils/omit.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/omit.js +11 -0
- package/dist/node_modules/ali-oss/lib/common/utils/omit.ts +9 -0
- package/dist/node_modules/ali-oss/lib/common/utils/policy2Str.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/policy2Str.js +21 -0
- package/dist/node_modules/ali-oss/lib/common/utils/policy2Str.ts +15 -0
- package/dist/node_modules/ali-oss/lib/common/utils/retry.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/common/utils/retry.js +30 -0
- package/dist/node_modules/ali-oss/lib/common/utils/retry.ts +26 -0
- package/dist/node_modules/ali-oss/lib/common/utils/setRegion.d.ts +3 -0
- package/dist/node_modules/ali-oss/lib/common/utils/setRegion.js +20 -0
- package/dist/node_modules/ali-oss/lib/common/utils/setRegion.ts +15 -0
- package/dist/node_modules/ali-oss/lib/common/utils/setSTSToken.d.ts +2 -0
- package/dist/node_modules/ali-oss/lib/common/utils/setSTSToken.js +36 -0
- package/dist/node_modules/ali-oss/lib/common/utils/setSTSToken.ts +32 -0
- package/dist/node_modules/ali-oss/lib/global.d.ts +6 -0
- package/dist/node_modules/ali-oss/lib/image.js +146 -0
- package/dist/node_modules/ali-oss/lib/managed-upload.js +380 -0
- package/dist/node_modules/ali-oss/lib/object.js +420 -0
- package/dist/node_modules/ali-oss/lib/rtmp.js +295 -0
- package/dist/node_modules/ali-oss/lib/setConfig.d.ts +3 -0
- package/dist/node_modules/ali-oss/lib/setConfig.js +42 -0
- package/dist/node_modules/ali-oss/lib/setConfig.ts +52 -0
- package/dist/node_modules/ali-oss/lib/sts.js +156 -0
- package/dist/node_modules/ali-oss/lib/types/experimental.d.ts +1 -0
- package/dist/node_modules/ali-oss/lib/types/experimental.js +2 -0
- package/dist/node_modules/ali-oss/lib/types/experimental.ts +1 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/.editorconfig +17 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/.idea/.name +1 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/.idea/bowser.iml +8 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/.idea/encodings.xml +6 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/.idea/jsLibraryMappings.xml +8 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/.idea/markdown-exported-files.xml +8 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/.idea/markdown-navigator/profiles_settings.xml +3 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/.idea/markdown-navigator.xml +67 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/.idea/misc.xml +6 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/.idea/modules.xml +8 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/.idea/vcs.xml +6 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/.idea/watcherTasks.xml +4 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/.idea/workspace.xml +696 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/.travis.yml +8 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/bower.json +33 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/bowser.js +644 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/bowser.min.js +6 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/package.json +38 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/src/bowser.js +644 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/test/test.js +151 -0
- package/dist/node_modules/ali-oss/node_modules/bowser/typings.d.ts +115 -0
- package/dist/node_modules/ali-oss/node_modules/dateformat/.vs/ProjectSettings.json +3 -0
- package/dist/node_modules/ali-oss/node_modules/dateformat/.vs/config/applicationhost.config +1031 -0
- package/dist/node_modules/ali-oss/node_modules/dateformat/.vs/node-dateformat/v15/.suo +0 -0
- package/dist/node_modules/ali-oss/node_modules/dateformat/.vs/slnx.sqlite +0 -0
- package/dist/node_modules/ali-oss/node_modules/dateformat/lib/dateformat.js +226 -0
- package/dist/node_modules/ali-oss/node_modules/dateformat/package.json +30 -0
- package/dist/node_modules/ali-oss/node_modules/mime/Mime.js +97 -0
- package/dist/node_modules/ali-oss/node_modules/mime/cli.js +46 -0
- package/dist/node_modules/ali-oss/node_modules/mime/index.js +4 -0
- package/dist/node_modules/ali-oss/node_modules/mime/lite.js +4 -0
- package/dist/node_modules/ali-oss/node_modules/mime/package.json +52 -0
- package/dist/node_modules/ali-oss/node_modules/mime/types/other.js +1 -0
- package/dist/node_modules/ali-oss/node_modules/mime/types/standard.js +1 -0
- package/dist/node_modules/ali-oss/package.json +1 -0
- package/dist/node_modules/ali-oss/shims/crypto/crypto.js +98 -0
- package/dist/node_modules/ali-oss/shims/crypto/helpers.js +36 -0
- package/dist/node_modules/ali-oss/shims/crypto/md5.js +152 -0
- package/dist/node_modules/ali-oss/shims/crypto/sha.js +91 -0
- package/dist/node_modules/ali-oss/shims/crypto/sha256.js +163 -0
- package/dist/node_modules/ali-oss/shims/debug.js +3 -0
- package/dist/node_modules/ali-oss/shims/is-type-of.js +18 -0
- package/dist/node_modules/ali-oss/shims/process.js +35 -0
- package/dist/node_modules/ali-oss/shims/stream-http/index.js +82 -0
- package/dist/node_modules/ali-oss/shims/stream-http/lib/capability.js +72 -0
- package/dist/node_modules/ali-oss/shims/stream-http/lib/request.js +320 -0
- package/dist/node_modules/ali-oss/shims/stream-http/lib/response.js +217 -0
- package/dist/node_modules/ali-oss/shims/url/index.js +696 -0
- package/dist/node_modules/ali-oss/shims/url/util.js +16 -0
- package/dist/node_modules/ali-oss/shims/utility.js +25 -0
- package/dist/node_modules/ali-oss/shims/xhr.js +798 -0
- package/dist/node_modules/mime-match/package.json +1 -1
- package/dist/node_modules/mime-types/package.json +1 -1
- package/dist/node_modules/mkdirp/package.json +1 -1
- package/dist/node_modules/multer-cos/package.json +1 -1
- package/dist/node_modules/url-join/package.json +1 -1
- package/dist/server/actions/storages.js +4 -6
- package/dist/server/server.js +1 -0
- package/dist/server/storages/ali-oss.d.ts +15 -1
- package/dist/server/storages/ali-oss.js +66 -2
- package/dist/server/storages/index.d.ts +1 -0
- package/dist/server/storages/local.js +1 -1
- package/dist/server/storages/s3.d.ts +10 -3
- package/dist/server/storages/s3.js +121 -29
- package/dist/server/storages/tx-cos.js +1 -1
- package/dist/server/utils.d.ts +1 -0
- package/dist/server/utils.js +43 -0
- package/package.json +7 -3
- package/dist/node_modules/multer-aliyun-oss/package.json +0 -1
- package/dist/node_modules/multer-s3/.gitattributes +0 -1
- package/dist/node_modules/multer-s3/.travis.yml +0 -6
- package/dist/node_modules/multer-s3/package.json +0 -1
- package/dist/node_modules/multer-s3/test/basic.js +0 -293
- package/dist/node_modules/multer-s3/test/files/a.txt +0 -1
- package/dist/node_modules/multer-s3/test/files/test.svg +0 -3
- package/dist/node_modules/multer-s3/test/files/test2.svg +0 -9
- package/dist/node_modules/multer-s3/test/util/mock-s3.js +0 -17
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const is = require('is-type-of');
|
|
3
|
+
const util = require('util');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const mime = require('mime');
|
|
6
|
+
const { isFile } = require('./common/utils/isFile');
|
|
7
|
+
const { isArray } = require('./common/utils/isArray');
|
|
8
|
+
const { isBuffer } = require('./common/utils/isBuffer');
|
|
9
|
+
const { retry } = require('./common/utils/retry');
|
|
10
|
+
|
|
11
|
+
const proto = exports;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Multipart operations
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Upload a file to OSS using multipart uploads
|
|
19
|
+
* @param {String} name
|
|
20
|
+
* @param {String|File|Buffer} file
|
|
21
|
+
* @param {Object} options
|
|
22
|
+
* {Object} options.callback The callback parameter is composed of a JSON string encoded in Base64
|
|
23
|
+
* {String} options.callback.url the OSS sends a callback request to this URL
|
|
24
|
+
* {String} options.callback.host The host header value for initiating callback requests
|
|
25
|
+
* {String} options.callback.body The value of the request body when a callback is initiated
|
|
26
|
+
* {String} options.callback.contentType The Content-Type of the callback requests initiatiated
|
|
27
|
+
* {Object} options.callback.customValue Custom parameters are a map of key-values, e.g:
|
|
28
|
+
* customValue = {
|
|
29
|
+
* key1: 'value1',
|
|
30
|
+
* key2: 'value2'
|
|
31
|
+
* }
|
|
32
|
+
*/
|
|
33
|
+
proto.multipartUpload = async function multipartUpload(name, file, options) {
|
|
34
|
+
this.resetCancelFlag();
|
|
35
|
+
options = options || {};
|
|
36
|
+
if (options.checkpoint && options.checkpoint.uploadId) {
|
|
37
|
+
return await this._resumeMultipart(options.checkpoint, options);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const minPartSize = 100 * 1024;
|
|
41
|
+
if (!options.mime) {
|
|
42
|
+
if (isFile(file)) {
|
|
43
|
+
options.mime = mime.getType(path.extname(file.name));
|
|
44
|
+
} else if (isBuffer(file)) {
|
|
45
|
+
options.mime = '';
|
|
46
|
+
} else {
|
|
47
|
+
options.mime = mime.getType(path.extname(file));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
options.headers = options.headers || {};
|
|
51
|
+
this._convertMetaToHeaders(options.meta, options.headers);
|
|
52
|
+
|
|
53
|
+
const fileSize = await this._getFileSize(file);
|
|
54
|
+
if (fileSize < minPartSize) {
|
|
55
|
+
options.contentLength = fileSize;
|
|
56
|
+
const result = await this.put(name, file, options);
|
|
57
|
+
if (options && options.progress) {
|
|
58
|
+
await options.progress(1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const ret = {
|
|
62
|
+
res: result.res,
|
|
63
|
+
bucket: this.options.bucket,
|
|
64
|
+
name,
|
|
65
|
+
etag: result.res.headers.etag
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
if ((options.headers && options.headers['x-oss-callback']) || options.callback) {
|
|
69
|
+
ret.data = result.data;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return ret;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (options.partSize && !(parseInt(options.partSize, 10) === options.partSize)) {
|
|
76
|
+
throw new Error('partSize must be int number');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (options.partSize && options.partSize < minPartSize) {
|
|
80
|
+
throw new Error(`partSize must not be smaller than ${minPartSize}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const initResult = await this.initMultipartUpload(name, options);
|
|
84
|
+
const { uploadId } = initResult;
|
|
85
|
+
const partSize = this._getPartSize(fileSize, options.partSize);
|
|
86
|
+
|
|
87
|
+
const checkpoint = {
|
|
88
|
+
file,
|
|
89
|
+
name,
|
|
90
|
+
fileSize,
|
|
91
|
+
partSize,
|
|
92
|
+
uploadId,
|
|
93
|
+
doneParts: []
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
if (options && options.progress) {
|
|
97
|
+
await options.progress(0, checkpoint, initResult.res);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return await this._resumeMultipart(checkpoint, options);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/*
|
|
104
|
+
* Resume multipart upload from checkpoint. The checkpoint will be
|
|
105
|
+
* updated after each successful part upload.
|
|
106
|
+
* @param {Object} checkpoint the checkpoint
|
|
107
|
+
* @param {Object} options
|
|
108
|
+
*/
|
|
109
|
+
proto._resumeMultipart = async function _resumeMultipart(checkpoint, options) {
|
|
110
|
+
const that = this;
|
|
111
|
+
if (this.isCancel()) {
|
|
112
|
+
throw this._makeCancelEvent();
|
|
113
|
+
}
|
|
114
|
+
const { file, fileSize, partSize, uploadId, doneParts, name } = checkpoint;
|
|
115
|
+
|
|
116
|
+
const partOffs = this._divideParts(fileSize, partSize);
|
|
117
|
+
const numParts = partOffs.length;
|
|
118
|
+
let uploadPartJob = retry(
|
|
119
|
+
(self, partNo) => {
|
|
120
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
121
|
+
return new Promise(async (resolve, reject) => {
|
|
122
|
+
try {
|
|
123
|
+
if (!self.isCancel()) {
|
|
124
|
+
const pi = partOffs[partNo - 1];
|
|
125
|
+
const stream = await self._createStream(file, pi.start, pi.end);
|
|
126
|
+
const data = {
|
|
127
|
+
stream,
|
|
128
|
+
size: pi.end - pi.start
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
if (isArray(self.multipartUploadStreams)) {
|
|
132
|
+
self.multipartUploadStreams.push(data.stream);
|
|
133
|
+
} else {
|
|
134
|
+
self.multipartUploadStreams = [data.stream];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const removeStreamFromMultipartUploadStreams = function () {
|
|
138
|
+
if (!stream.destroyed) {
|
|
139
|
+
stream.destroy();
|
|
140
|
+
}
|
|
141
|
+
const index = self.multipartUploadStreams.indexOf(stream);
|
|
142
|
+
if (index !== -1) {
|
|
143
|
+
self.multipartUploadStreams.splice(index, 1);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
stream.on('close', removeStreamFromMultipartUploadStreams);
|
|
148
|
+
stream.on('error', removeStreamFromMultipartUploadStreams);
|
|
149
|
+
|
|
150
|
+
let result;
|
|
151
|
+
try {
|
|
152
|
+
result = await self._uploadPart(name, uploadId, partNo, data, options);
|
|
153
|
+
} catch (error) {
|
|
154
|
+
removeStreamFromMultipartUploadStreams();
|
|
155
|
+
if (error.status === 404) {
|
|
156
|
+
throw self._makeAbortEvent();
|
|
157
|
+
}
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
if (!self.isCancel()) {
|
|
161
|
+
doneParts.push({
|
|
162
|
+
number: partNo,
|
|
163
|
+
etag: result.res.headers.etag
|
|
164
|
+
});
|
|
165
|
+
checkpoint.doneParts = doneParts;
|
|
166
|
+
|
|
167
|
+
if (options.progress) {
|
|
168
|
+
await options.progress(doneParts.length / (numParts + 1), checkpoint, result.res);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
resolve();
|
|
173
|
+
} catch (err) {
|
|
174
|
+
err.partNum = partNo;
|
|
175
|
+
reject(err);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
this.options.retryMax,
|
|
180
|
+
{
|
|
181
|
+
errorHandler: err => {
|
|
182
|
+
const _errHandle = _err => {
|
|
183
|
+
const statusErr = [-1, -2].includes(_err.status);
|
|
184
|
+
const requestErrorRetryHandle = this.options.requestErrorRetryHandle || (() => true);
|
|
185
|
+
return statusErr && requestErrorRetryHandle(_err);
|
|
186
|
+
};
|
|
187
|
+
return !!_errHandle(err);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
const all = Array.from(new Array(numParts), (x, i) => i + 1);
|
|
193
|
+
const done = doneParts.map(p => p.number);
|
|
194
|
+
const todo = all.filter(p => done.indexOf(p) < 0);
|
|
195
|
+
|
|
196
|
+
const defaultParallel = 5;
|
|
197
|
+
const parallel = options.parallel || defaultParallel;
|
|
198
|
+
|
|
199
|
+
if (this.checkBrowserAndVersion('Internet Explorer', '10') || parallel === 1) {
|
|
200
|
+
for (let i = 0; i < todo.length; i++) {
|
|
201
|
+
if (this.isCancel()) {
|
|
202
|
+
throw this._makeCancelEvent();
|
|
203
|
+
}
|
|
204
|
+
/* eslint no-await-in-loop: [0] */
|
|
205
|
+
await uploadPartJob(this, todo[i]);
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
// upload in parallel
|
|
209
|
+
const jobErr = await this._parallel(todo, parallel, value => {
|
|
210
|
+
return new Promise((resolve, reject) => {
|
|
211
|
+
uploadPartJob(that, value)
|
|
212
|
+
.then(() => {
|
|
213
|
+
resolve();
|
|
214
|
+
})
|
|
215
|
+
.catch(reject);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
const abortEvent = jobErr.find(err => err.name === 'abort');
|
|
220
|
+
if (abortEvent) throw abortEvent;
|
|
221
|
+
|
|
222
|
+
if (this.isCancel()) {
|
|
223
|
+
uploadPartJob = null;
|
|
224
|
+
throw this._makeCancelEvent();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (jobErr && jobErr.length > 0) {
|
|
228
|
+
jobErr[0].message = `Failed to upload some parts with error: ${jobErr[0].toString()} part_num: ${
|
|
229
|
+
jobErr[0].partNum
|
|
230
|
+
}`;
|
|
231
|
+
throw jobErr[0];
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return await this.completeMultipartUpload(name, uploadId, doneParts, options);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Get file size
|
|
240
|
+
*/
|
|
241
|
+
proto._getFileSize = async function _getFileSize(file) {
|
|
242
|
+
if (isBuffer(file)) {
|
|
243
|
+
return file.length;
|
|
244
|
+
} else if (isFile(file)) {
|
|
245
|
+
return file.size;
|
|
246
|
+
} else if (is.string(file)) {
|
|
247
|
+
const stat = await this._statFile(file);
|
|
248
|
+
return stat.size;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
throw new Error('_getFileSize requires Buffer/File/String.');
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
/*
|
|
255
|
+
* Readable stream for Web File
|
|
256
|
+
*/
|
|
257
|
+
const { Readable } = require('stream');
|
|
258
|
+
|
|
259
|
+
function WebFileReadStream(file, options) {
|
|
260
|
+
if (!(this instanceof WebFileReadStream)) {
|
|
261
|
+
return new WebFileReadStream(file, options);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
Readable.call(this, options);
|
|
265
|
+
|
|
266
|
+
this.file = file;
|
|
267
|
+
this.reader = new FileReader();
|
|
268
|
+
this.start = 0;
|
|
269
|
+
this.finish = false;
|
|
270
|
+
this.fileBuffer = null;
|
|
271
|
+
}
|
|
272
|
+
util.inherits(WebFileReadStream, Readable);
|
|
273
|
+
|
|
274
|
+
WebFileReadStream.prototype.readFileAndPush = function readFileAndPush(size) {
|
|
275
|
+
if (this.fileBuffer) {
|
|
276
|
+
let pushRet = true;
|
|
277
|
+
while (pushRet && this.fileBuffer && this.start < this.fileBuffer.length) {
|
|
278
|
+
const { start } = this;
|
|
279
|
+
let end = start + size;
|
|
280
|
+
end = end > this.fileBuffer.length ? this.fileBuffer.length : end;
|
|
281
|
+
this.start = end;
|
|
282
|
+
pushRet = this.push(this.fileBuffer.slice(start, end));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
WebFileReadStream.prototype._read = function _read(size) {
|
|
288
|
+
if (
|
|
289
|
+
(this.file && this.start >= this.file.size) ||
|
|
290
|
+
(this.fileBuffer && this.start >= this.fileBuffer.length) ||
|
|
291
|
+
this.finish ||
|
|
292
|
+
(this.start === 0 && !this.file)
|
|
293
|
+
) {
|
|
294
|
+
if (!this.finish) {
|
|
295
|
+
this.fileBuffer = null;
|
|
296
|
+
this.finish = true;
|
|
297
|
+
}
|
|
298
|
+
this.push(null);
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const defaultReadSize = 16 * 1024;
|
|
303
|
+
size = size || defaultReadSize;
|
|
304
|
+
|
|
305
|
+
const that = this;
|
|
306
|
+
this.reader.onload = function (e) {
|
|
307
|
+
that.fileBuffer = Buffer.from(new Uint8Array(e.target.result));
|
|
308
|
+
that.file = null;
|
|
309
|
+
that.readFileAndPush(size);
|
|
310
|
+
};
|
|
311
|
+
this.reader.onerror = function onload(e) {
|
|
312
|
+
const error = e.srcElement && e.srcElement.error;
|
|
313
|
+
if (error) {
|
|
314
|
+
throw error;
|
|
315
|
+
}
|
|
316
|
+
throw e;
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
if (this.start === 0) {
|
|
320
|
+
this.reader.readAsArrayBuffer(this.file);
|
|
321
|
+
} else {
|
|
322
|
+
this.readFileAndPush(size);
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
proto._createStream = function _createStream(file, start, end) {
|
|
327
|
+
if (is.readableStream(file)) {
|
|
328
|
+
return file;
|
|
329
|
+
} else if (isFile(file)) {
|
|
330
|
+
return new WebFileReadStream(file.slice(start, end));
|
|
331
|
+
} else if (isBuffer(file)) {
|
|
332
|
+
const iterable = file.subarray(start, end);
|
|
333
|
+
// we can't use Readable.from() since it is only support in Node v10
|
|
334
|
+
return new Readable({
|
|
335
|
+
read() {
|
|
336
|
+
this.push(iterable);
|
|
337
|
+
this.push(null);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
} else if (is.string(file)) {
|
|
341
|
+
return fs.createReadStream(file, {
|
|
342
|
+
start,
|
|
343
|
+
end: end - 1
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
throw new Error('_createStream requires Buffer/File/String.');
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
proto._getPartSize = function _getPartSize(fileSize, partSize) {
|
|
350
|
+
const maxNumParts = 10 * 1000;
|
|
351
|
+
const defaultPartSize = 1 * 1024 * 1024;
|
|
352
|
+
|
|
353
|
+
if (!partSize) partSize = defaultPartSize;
|
|
354
|
+
const safeSize = Math.ceil(fileSize / maxNumParts);
|
|
355
|
+
|
|
356
|
+
if (partSize < safeSize) {
|
|
357
|
+
partSize = safeSize;
|
|
358
|
+
console.warn(
|
|
359
|
+
`partSize has been set to ${partSize}, because the partSize you provided causes partNumber to be greater than 10,000`
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
return partSize;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
proto._divideParts = function _divideParts(fileSize, partSize) {
|
|
366
|
+
const numParts = Math.ceil(fileSize / partSize);
|
|
367
|
+
|
|
368
|
+
const partOffs = [];
|
|
369
|
+
for (let i = 0; i < numParts; i++) {
|
|
370
|
+
const start = partSize * i;
|
|
371
|
+
const end = Math.min(start + partSize, fileSize);
|
|
372
|
+
|
|
373
|
+
partOffs.push({
|
|
374
|
+
start,
|
|
375
|
+
end
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return partOffs;
|
|
380
|
+
};
|