Version - 0.0.1

Upload Media

The uploadFile function facilitates the uploading of photos or videos by accepting the context and the URI of the local file path as parameters.

Our transcriptions module simplifies video transcription. Upload videos effortlessly, initiate transcription, and retrieve results seamlessly, it's ideal for content management, media monitoring, and educational platforms.

Example Usage :

Future<void> performUploadFlow(String filePath) async {
  try {
    // Create a new MediaBuilder with a test file path
    final builder = MediaBuilder(filePath)
      ..setTag("color", "blue")
      ..setTag("source", "flutter-sdk")
      ..setMetaData("uploadedBy", "truvideo");
 
    // Build the media upload request
    await builder.build();
 
    final mediaId = builder.getMediaId();
    print("Upload media ID is: $mediaId");
 
    // Start the upload with event callbacks
    await builder.upload(
      onProgress: (e) => print("Upload Progess: ${e['progress']}%"),
      onComplete: (e) => print("Upload Complete: ${e['remoteURL']}"),
      onError: (e) => print("Upload Failed: ${e['error']}"),
    );
  } catch (e) {
    debugPrint('Upload flow failed: $e');
  }
}

Note

Both functions are designed to upload a media file using the TruvideoSdkMedia SDK. The first function (uploadFile(videoPath:)) uses a simpler metadata and tag initialization method. The second function (uploadFile(at:)) is more flexible, using a URL parameter and allows for more complex nested metadata.

These functions can be adapted and extended based on specific requirements, such as adding more tags, customizing metadata, or modifying the progress and completion handling logic.

await builder.upload(
      onProgress: (e) => print("Upload Progess: ${e['progress']}%"),
      onComplete: (e) => print("Upload Complete: ${e['remoteURL']}"),
      onError: (e) => print("Upload Failed: ${e['error']}"),
    );

Last updated

Was this helpful?