0.3.0
Upload Progress Callbacks
Track upload progress in real-time when submitting large video files through the Queue API.
Quick Start — Upload Progress
// Simple lambda syntax (UploadProgressListener is a fun interface)
client.queue.submitAndPoll(
model = VideoModels.LUCY_2_V2V,
input = VideoEditInput(
prompt = "Transform into Studio Ghibli anime style",
data = FileInput.fromUri(videoUri),
),
onUploadProgress = { bytesWritten, totalBytes ->
if (totalBytes > 0) {
val percent = (bytesWritten * 100 / totalBytes).toInt()
Log.d("Upload", "Progress: $percent%")
}
}
)
// With submitAndObserve (Flow) — trailing lambda
client.queue.submitAndObserve(model, input) { bytesWritten, totalBytes ->
updateProgressBar(bytesWritten.toFloat() / totalBytes)
}.collect { update ->
when (update) {
is QueueJobResult.InProgress -> showStatus(update.status)
is QueueJobResult.Completed -> saveVideo(update.data)
is QueueJobResult.Failed -> showError(update.error)
}
}What's New
- Upload progress callbacks — New
UploadProgressListenerfun interface withonProgress(bytesWritten, totalBytes), available onsubmit,submitAndPoll, andsubmitAndObserve - Streaming progress tracking — Uses OkHttp
ForwardingSinkpattern to count bytes as they're written to the network, with zero extra buffering - Sample app — Queue tab now shows a
LinearProgressIndicatorwith "Uploading... X%" during file upload
What's Changed
- Add upload progress callbacks for queue API in #2
Full Changelog: 0.2.0...0.3.0