Skip to main content
Version: Android SDK v1.0.3

Upload Videos

When using the VideoKit recorder, videos will be automatically uploaded as soon as you start recording. However, you are free to upload other videos through our system. The entry point is represented by the upload manager returned by VideoKit.uploads().

Note that while video upload can take some time, if the app is killed while the upload is in progress, they are automatically resumed as soon as the app is reopened. The same logic stands for connection problems.

Upload videos

To upload videos, you need to create an upload request:

// Option 1: Simple constructor
val request = UploadRequest(title = "My Video")

// Option 2: Java-style builder
val request = UploadRequest.builder()
.title("My Video")
.tags("My Tag")
.metadata("My Key", "My Value")
.build()

// Option 3: Kotlin-friendly builder
val request = UploadRequest.builder() {
title("My Video")
tags("My Tag")
metadata("My Key", "My Value")
}

Then, the request must be passed to the upload manager:

val uploads: UploadManager = VideoKit.uploads()
val upload = uploads.upload(videoUri, request)

Check the upload state

The upload() method will return an Upload object which contains useful information and data, including the Video object that is going to be saved to network.

To check the upload state, you can add a listener:

val uploads: UploadManager = VideoKit.uploads()
uploads.addListener(object: UploadListener {
// Upload has started
override fun onUploadStarted(upload: Upload) { ... }

// Upload is making progress. Check the Upload object to know.
fun onUploadProgress(upload: Upload)

// Upload was completed successfully and the video should be soon available
// to other users of your app-
fun onUploadCompleted(upload: Upload, video: Video)

// Signals an unrecoverable error during the video upload.
fun onUploadError(upload: Upload, error: VideoError)
})

To query all the pending uploads, the VideoKit.uploads().uploads property will return a list of Upload objects.

Cancel uploads

The upload manager provides utilities to cancel the upload for a given id, Uri or Upload:

val uploads: UploadManager = VideoKit.uploads()
uploads.cancel(video.id) // cancel by id
uploads.cancel(uri) // cancel by Uri
uploads.cancel(upload) // cancel by Upload