Skip to content

Commit fcfc91a

Browse files
authored
Merge pull request #44 from transloadit/codex/tus-chunk-size-and-upload-docs
Expose TUS upload chunk size
2 parents b15718d + 489109d commit fcfc91a

5 files changed

Lines changed: 161 additions & 85 deletions

File tree

.github/workflows/transloaditkit-ci.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,11 @@ name: CI
22
on: [push, workflow_dispatch]
33
jobs:
44
build:
5-
name: Swift ${{ matrix.swift }} on ${{ matrix.os }}
6-
strategy:
7-
matrix:
8-
os: ["macos-latest"]
9-
swift: ["6.0.2"]
10-
runs-on: ${{ matrix.os }}
5+
name: Swift on macos-latest
6+
runs-on: macos-latest
117
steps:
128
- name: Extract Branch Name
139
run: echo "BRANCH=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
14-
- uses: swift-actions/setup-swift@v2
15-
with:
16-
swift-version: ${{ matrix.swift }}
1710
- name: Get swift version
1811
run: swift --version
1912
- uses: actions/checkout@v2

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# TransloaditKit Changelog
22

3+
## Next
4+
5+
* Added `tusUploadChunkSize` to Transloadit initializers so apps can tune TUS chunking behavior, including single-request uploads with `0`.
6+
* Clarified that `createAssembly(... andUpload ..., completion:)` completes after upload scheduling, not after file upload or processing completion.
7+
38
## 3.5.0
49

510
* Allow clients to inject only an api key and provide a signature generator closure to calculate signatures for signing requests instead of injecting a key and secret. ([#42](https://github.com/transloadit/TransloaditKit/issues/42))
@@ -34,7 +39,7 @@
3439
### Fixes
3540

3641
### Added
37-
* It's now possible to cancel a running Assembly
42+
* It's now possible to cancel a running Assembly
3843
* Bumped TUSKit version
3944
* Allow passing of custom fields to assembly creating by passing them to `createAssembly` methods
4045

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ To do this, use the `Transloadit` initializer that takes an api key and a `signa
4545

4646
```swift
4747
let transloadit = Transloadit(
48-
apiKey: "YOUR-API-KEY",
49-
sessionConfiguration: .default,
48+
apiKey: "YOUR-API-KEY",
49+
sessionConfiguration: .default,
5050
signatureGenerator: { stringToSign, onSignatureGenerated in
51-
mySigningService.sign(stringToSign) { result in
51+
mySigningService.sign(stringToSign) { result in
5252
onSignatureGenerated(result)
5353
}
5454
})
@@ -63,7 +63,7 @@ public typealias SignatureGenerator = (String, SignatureCompletion) -> Void
6363

6464
The generator itself is passed a string that needs to be signed (a JSON representation of the request parameters that you're generating a signature for) and a closure that you _must_ call to inform the SDK when you're done generating the signature (whether it's successful or failed).
6565

66-
**Important** if you don't call the completion handler, your requests will never be sent. The SDK does not implement a fallback or timeout.
66+
**Important** if you don't call the completion handler, your requests will never be sent. The SDK does not implement a fallback or timeout.
6767

6868
The SDK will invoke the signature generator for every request that requires a signature. It will pass a parameter string for each request to your closure which you can then send to your service (local or external) for signature generation.
6969

@@ -73,6 +73,18 @@ To learn more about signature generation see this page: https://transloadit.com/
7373

7474
To create an `Assembly` you invoke `createAssembly(steps:andUpload:completion)` on `Transloadit`.
7575
It returns a `TransloaditPoller` that you can use to poll for the `AssemblyStatus` of your `Assembly`.
76+
The completion handler is called after the Assembly has been created and uploads have been scheduled. It does not mean the files have finished uploading.
77+
Use `TransloaditFileDelegate.didFinishUpload` to detect file upload completion, and use the returned poller to wait for processing completion.
78+
79+
By default, TUS uploads are split into 500 KiB chunks. For iOS background uploads, this means the system needs to schedule a new upload task for every chunk.
80+
If that is too aggressive for your app, configure a larger `tusUploadChunkSize`, or pass `0` to let TUSKit upload each file in one request:
81+
82+
```swift
83+
let transloadit = Transloadit(
84+
credentials: credentials,
85+
sessionConfiguration: .background(withIdentifier: "com.example.uploads"),
86+
tusUploadChunkSize: 0)
87+
```
7688

7789
```swift
7890
let resizeStep = Step(
@@ -83,7 +95,7 @@ let resizeStep = Step(
8395
"height": 100,
8496
"resize_strategy": "fit",
8597
"result": true])
86-
98+
8799
let filesToUpload: [URL] = ...
88100
transloadit.createAssembly(steps: [resizeStep], andUpload: filesToUpload) { result in
89101
switch result {

0 commit comments

Comments
 (0)