Upload Media

This documentation provides guidelines on uploading images and video to server using the TruVideo Media SDK. The SDK offers simple methods to integrate upload functionalities into your application.

Prerequisites

  • Ensure you have integrated the TruVideo Core SDK into your project and completed with the authentication process

  • Camera module will provide MediaItem or simply provide filepath to upload (optional)

Step 1 : Create a MediaBuilder object

final TruvideoSdkMediaFileUploadRequestBuilder builder = TruvideoSdkMedia.getInstance().FileUploadRequestBuilder(filePath);

Step 2 : Set tags or metaData mediaBuilder object if required

// Option 1: use the file upload request builder directly
builder.addTag("key", "value");
builder.addTag("color", "red");
builder.addTag("order-number", "123");

// Option 2: use the tag builder
TruvideoSdkMediaTags tags = TruvideoSdkMediaTags.builder()
        .set("key", "value")
        .set("color", "red")
        .set("order-number", "123")
        .build();
builder.setTags(tags);

// --------------------------
// Metadata
// --------------------------
// Option 1: use the file upload request builder directly
builder.addMetadata("key", "value");
builder.addMetadata("list", new String[]{"value1", "value2"});
builder.addMetadata("nested", TruvideoSdkMediaMetadata.builder()
    .set("key", "value")
    .set("list", new String[]{"value1", "value2"})
    .build()
);


// Option 2: use the metadata builder
TruvideoSdkMediaMetadata metadata = TruvideoSdkMediaMetadata
    .builder()
    .set("key", "value")
    .set("list", new String[]{"value1", "value2"})
    .set("nested", TruvideoSdkMediaMetadata.builder()
            .set("key", "value")
            .set("list", new String[]{"value1", "value2"})
            .build()
    )
    .build();
builder.setMetadata(metadata);

Step 3 : Build the request with mediaBuilder

Step 4 : Create object for getting callbacks from the SDK

Step 5 : Finally call the upload to push data to server

Finalize :

After completing this steps the function should look like

Last updated

Was this helpful?