You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,6 +98,29 @@ To upload multiple files at once, you can use the `uploadFiles(filePaths:)` meth
98
98
99
99
To specify a custom upload URL (e.g. for TransloadIt) or custom headers to be added to a file upload, please refer to the `uploadURL` and `customHeaders` properties in the methods related to uploading. Such as: `upload`, `uploadFileAt`, `uploadFiles` or `uploadMultiple(dataFiles:)`.
100
100
101
+
### Custom header generation
102
+
103
+
Sometimes headers need to be signed or refreshed right before a request is sent.
104
+
`TUSClient` exposes a header generation hook so you can mutate previously supplied custom headers without rebuilding the upload. Pass the optional `generateHeaders` closure to the initializer and TUSKit will call it before every `POST`, `PATCH`, or `HEAD` request.
105
+
106
+
```swift
107
+
let client =tryTUSClient(
108
+
server: serverURL,
109
+
sessionIdentifier: "UploadSession",
110
+
sessionConfiguration: configuration,
111
+
storageDirectory: storageDirectory,
112
+
supportedExtensions: [.creation]
113
+
) { uploadID, headers, onHeadersGenerated in
114
+
tokenProvider.fetchToken(for: uploadID) { token in
TUSKit will reuse whatever headers you return for automatic retries or when resuming an upload, ensuring the same values are applied consistently. New headers can be introduced as needed, while core TUS headers such as `Upload-Offset` and `Content-Length` remain under the SDK’s control.
123
+
101
124
## Measuring upload progress
102
125
103
126
To know how many files have yet to be uploaded, please refer to the `remainingUploads` property.
0 commit comments