1313- [ Extensions] ( #extensions )
1414- [ Examples] ( #examples )
1515 - [ Example: using ` credentials ` to fetch credentials inside a AWS container] ( #example-using-credentials-to-fetch-credentials-inside-a-aws-container )
16+ - [ Example: use with Cloudflare R2] ( #example-use-with-cloudflare-r2 )
1617- [ Types] ( #types )
1718- [ Compatibility] ( #compatibility )
1819- [ Contribute] ( #contribute )
@@ -61,10 +62,20 @@ The bucket name.
6162
6263#### ` options.partSize `
6364
64- The preferred part size for parts send to S3. Can not be lower than 5MiB or more than
65+ The ** preferred** part size for parts send to S3. Can not be lower than 5MiB or more than
65665GiB. The server calculates the optimal part size, which takes this size into account, but
6667may increase it to not exceed the S3 10K parts limit.
6768
69+ #### ` options.minPartSize `
70+
71+ The minimal part size for parts.
72+ Can be used to ensure that all non-trailing parts are exactly the same size
73+ by setting ` partSize ` and ` minPartSize ` to the same value.
74+ Can not be lower than 5MiB or more than 5GiB.
75+
76+ The server calculates the optimal part size, which takes this size into account, but
77+ may increase it to not exceed the S3 10K parts limit.
78+
6879#### ` options.s3ClientConfig `
6980
7081Options to pass to the AWS S3 SDK. Checkout the
@@ -182,7 +193,7 @@ docs for the supported values of
182193``` js
183194const aws = require (' aws-sdk' )
184195const {Server } = require (' @tus/server' )
185- const {FileStore } = require (' @tus/s3-store' )
196+ const {S3Store } = require (' @tus/s3-store' )
186197
187198const s3Store = new S3Store ({
188199 partSize: 8 * 1024 * 1024 ,
@@ -199,6 +210,22 @@ const server = new Server({path: '/files', datastore: s3Store})
199210// ...
200211```
201212
213+ ### Example: use with Cloudflare R2
214+
215+ ` @tus/s3-store ` can be used with all S3-compatible storage solutions, including Cloudflare R2.
216+ However R2 requires that all non-trailing parts are _ exactly_ the same size.
217+ This can be achieved by setting ` partSize ` and ` minPartSize ` to the same value.
218+
219+ ``` ts
220+ // ...
221+
222+ const s3Store = new S3Store ({
223+ partSize: 8 * 1024 * 1024 ,
224+ minPartSize: 8 * 1024 * 1024 ,
225+ // ...
226+ })
227+ ```
228+
202229## Types
203230
204231This package is fully typed with TypeScript.
0 commit comments