Upload Media

This guide outlines how to upload images or videos to the server using the TruVideo Media SDK. Whether you're working with captured media or a local file path, the SDK provides a streamlined way to handle uploads in your iOS application.


Prerequisites

Before proceeding, ensure the following:

  • The TruVideo Core SDK is integrated into your project.

  • User authentication is successfully completed.

  • Media files (from the camera module or local file path) are available for upload.


Step-by-Step Guide

Step 1: Create a Media Builder

Start by creating a FileUploadRequestBuilder using the file URL.

let builder = TruvideoSdkMedia.FileUploadRequestBuilder(fileURL: URL(string: videoPath)!)

Step 2: Set Tags and Metadata (Optional)

Tags and metadata help categorize and describe the uploaded media.

// Tags
builder.setTag("key", "value")
builder.setTag("color", "red")
builder.setTag("orderNumber", "123")

// Metadata
builder.setMetaData("key", "value")
builder.setMetaData("key1", "1")
builder.setMetaData("key2", "[4,5,6]")

Step 3: Build the Upload Request


Step 4: Handle Callbacks for Completion & Progress

Use Combine to handle the upload lifecycle.


Step 5: Start the Upload


Complete Function Example

Here’s a consolidated method that uploads a video file using the TruVideo SDK:


Notes

  • The SDK uses Combine for asynchronous event handling.

  • Tags and metadata are optional but useful for organizing and retrieving uploaded media.

  • Ensure file paths are valid URLs and the media exists before calling upload().

Last updated

Was this helpful?