Expose TUS upload chunk size#44
Conversation
|
@donnywals can you review this in hindsight please |
|
Looks okay overall with one caveat; if we decide to change the default chunk size in TUSKit, we have to also update TransloaditKit with the same value (the 500 * 1024 value is currently the default in TUSKit). One way to avoid this is to make It'd roughly look like this when building the TUSKit client: lazy var tusClient: TUSClient = {
let tusClient: TUSClient
if let tusUploadChunkSize {
tusClient = try! TUSClient(
server: URL(string:"https://www.transloadit.com")!,
sessionIdentifier: "TransloadIt",
sessionConfiguration: tusSessionConfig,
storageDirectory: storageDir,
chunkSize: tusUploadChunkSize
)
} else {
tusClient = try! TUSClient(
server: URL(string:"https://www.transloadit.com")!,
sessionIdentifier: "TransloadIt",
sessionConfiguration: tusSessionConfig,
storageDirectory: storageDir
)
}
tusClient.delegate = self
return tusClient
}()I think there's an argument to be made for the current approach being more explicit, and for each SDK to control its own default, I think it's important to make this decision and to decide whether that's the behavior we want, or if we want to consider the user's choice to not set a chunk size to equal "let TUSKit decide". |
What changed
tusUploadChunkSizeto the Transloadit initializers and passes it through to TUSKit.0to let TUSKit upload each file in one request, which can be useful for iOS background uploads where scheduling a new task for each 500 KiB chunk can stall.createAssembly(... andUpload ..., completion:)fires after the Assembly is created and uploads are scheduled, not after file upload or processing completion.TransloaditFileDelegate.didFinishUploadfor upload completion andpollAssemblyStatusfor processing completion.Why
A customer using TransloaditKit 3.5.0 saw
didFinishUpload()fire while API2 had already aborted the Assembly after seeing only three default TUS chunks. Exposing the chunk size gives apps a way to avoid many small background URLSession tasks, and the docs now make the upload lifecycle explicit.Validation
swift test