Skip to content

0.3.0

Choose a tag to compare

@tomershlasky tomershlasky released this 16 Mar 12:14
· 6 commits to main since this release
75df5fc

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 UploadProgressListener fun interface with onProgress(bytesWritten, totalBytes), available on submit, submitAndPoll, and submitAndObserve
  • Streaming progress tracking — Uses OkHttp ForwardingSink pattern to count bytes as they're written to the network, with zero extra buffering
  • Sample app — Queue tab now shows a LinearProgressIndicator with "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