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 prepare the upload parameters:
var params = UploadParams(title: "My Video")
params.tags = myTags
params.metadata = myMetadata
params.playbackPolicy = .signedPlayback
Then, this object must be passed to the upload manager:
let uploads: UploadManager = VideoKit.uploads()
let upload = uploads.enqueue(url: videoUrl, params: params)
The UploadManager.enqueue()
method will return an Upload
object which contains useful information and data,
including the Video
object that is going to be saved to network. The upload id
is a shorthand to video.id
and represents the id of the Video
that is being uploaded.
Check the upload state
To check the upload state, you must currently observe global notifications as described here, using the Upload.id
to filter them.
To query all the pending uploads, the UploadManager.uploads
property will return
a list of Upload
objects.
Cancel uploads
The upload manager provides utilities to cancel the upload for a given id, URL
or Upload
:
let uploads: UploadManager = VideoKit.uploads()
uploads.cancel(id: video.id) // cancel by id
uploads.cancel(url: url) // cancel by URL
uploads.cancel(upload: upload) // cancel by Upload