From cd31a51239afe70fee4b90cb6842b37a6d31483c Mon Sep 17 00:00:00 2001 From: shaloo <5890484+shaloo@users.noreply.github.com> Date: Mon, 14 Nov 2022 14:02:50 +0530 Subject: [PATCH] Fix: AR-4947 chunk size code example and user docs added --- .DS_Store | Bin 8196 -> 0 bytes usage.md | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index c692c05b1e6c279062d701dd320f3a660a976fae..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHMJ!n%=6h1diG57;jN$ny&akMRzLKi`vB?=X>NQb(JX?{owNndD_`h%1#4x)n= z#5y_Xpo6>U(m`+yj*5sNxG0E=gMxndC&{^aFCm?j_Fj1Ryxw!pJKy=v?R`D3L?otb zxe1~XB1+(ra%c~xh#~dz3XPaq8HE(^r&3{JE*q39AxpR57;p?Y1{?#90ms1q!T{dc zawNLE_qEo|jseHOj$}Zd4<0TleIx5ys-pvwY5^eQSXKk~L-GdFGtxJ*t|c@WLc2n0 zS7BNVq200W89U#|x|Z6VglRs6i7ZTqB2;ud-&5u!d@bGV7;p@P8IZkuoW`j@i&VAx z_r{+!t}6$rRHhVUu$K5aGdsKQ#_LnIKG#!UDYm~2h=bqZO1qkIsYo@-SkY;CK5W4; z1h*f(IDA22=y*;!Xd~%v#qsFlP2pLk70OaTIm+93)OjQ$F$<38-j^rIizixmEUPx2 z?p8J)b&4evl2yvnGA*D&Hlp>-A7ChC!!ezFJGOh{ioz6O*GARL&ce0ckadfLokj3u z@0a68-*X+uaenIR(j|?f<;$xSrMKdaZZ_iv;AF+F%;Y;0SLt}%TSvyf-pQMNnnP9L z%i~7rt+EQs2xw2sjTj5R6@2E&j%VGp7pZjx!n9TJotP~<{4$!_uJO;xUn}I&AKvw9y{8? zichLe(*GJ&Ix9mo`Ow5SS|0z*=Wj*xyT|-_{Add+zVHyhjcvxjfX-(`_W!55fB)ZR zS-W%`1C9aCfQYB&Qqx#5y*1aVd)aGyxYD@fkal$~l?x`-jzg+;9J2KfL)?2Xl|H_a ZbuF=i@ee)(xc9&HSFn5ktBttBroYKY#s~la diff --git a/usage.md b/usage.md index 04ac0e9..745a9ec 100644 --- a/usage.md +++ b/usage.md @@ -29,7 +29,7 @@ Refer to the [Arcana Storage SDK Quick Start Guide](https://docs.beta.arcana.net 1. Install Storage SDK 2. Import `StorageProvider` from the Storage SDK package in the dApp. Call `init` method of `StorageProvider` and specify the Web3 wallet `provider` and the `appAddress` as input parameters. **Note:** Get the provider via the Auth SDK or third-party supported wallet. You can copy the appAddress from the [Arcana Developer Dashboard](https://docs.beta.arcana.network/docs/config_dapp) after registering your dApp 3. Use `StorageProvider` to: - - `upload` and push file data into the Arcana Store. **Note:** Save file DID that is returned after file upload operation is successful. + - `upload` and push file data into the Arcana Store. **Note:** Save file DID that is returned after the file upload operation is successful. - `download` a file from the Arcana Store using DID as input. 4. Use `StorageProvider.files` to: - `delete` a file by specifying its DID. @@ -102,6 +102,21 @@ After a file is successfully uploaded to the Arcana Store, it is assigned a uniq let shareURL = await dAppStorageProvider.files.getPublicFileURL(did); ``` --> +### Upload Chunk Size + +Arcana Storage SDK uses chunked uploading mode. Each file is split into chunks of default size 10MB and chunks are uploaded one by one. These chunks are further processed on the server, encrypted, and split into multiple parts before being stored in the Arcana Store. Chunked uploading helps to overcome the server's default upload size limitation and there is no server-side setting change required to upload a very large file size. Also, it helps in decentralizing data storage. + +You can change the default chunk size while uploading a file. Make sure the new chunk size is a multiple of 16 otherwise there may be issues in downloading the file. + +```ts +// Upload a file and set the chunk size to 16 MB +await dAppStorageProvider.upload(file, {chunkSize: 16 * 2 ** 20},{ + onProgress: (bytesUploaded, bytesTotal) => { + console.log('Progress:', ((bytesUploaded / bytesTotal) * 100).toFixed(2), '%') + } +}).then((did) => console.log('File successfully uploaded in 16 MB chunks. DID:', did)).catch(e => console.error(e)); +``` + ## Download File ```ts @@ -290,4 +305,4 @@ returns `true` if required. ```js const isPermissionRequired = await storage.checkPermission() -> boolean -``` \ No newline at end of file +```