Create A New Kaltura Entry And Upload Video File Using The Kaltura API

Printer-friendly version

 

This short guide takes the user through the basic flow of uploading media using Kaltura's upload API.

 

To upload a video file using the C# API Client Library, follow the steps below.

  1. Handshake to create a Kaltura Session:
    KalturaConfiguration config = new KalturaConfiguration(PARTNER_ID);
    config.ServiceUrl = SERVICE_URL;
    KalturaClient client = new KalturaClient(config);
    client.KS = client.GenerateSession(ADMIN_SECRET, USER_ID, KalturaSessionType.ADMIN, PARTNER_ID, 86400, "");
  2. Create a new Media Entry to which we'll attach the uploaded file:

    KalturaMediaEntry mediaEntry = new KalturaMediaEntry();
    mediaEntry.Name = "Media Entry Using C#";
    mediaEntry.MediaType = KalturaMediaType.VIDEO;
    mediaEntry = client.MediaService.Add(mediaEntry);
  3. Upload the media File:

    FileStream fileStream = new FileStream("DemoVideo.flv", FileMode.Open, FileAccess.Read);
    KalturaUploadToken uploadToken = client.UploadTokenService.Add();
    client.UploadTokenService.Upload(uploadToken.Id, fileStream);
  4. Attach the Media Entry to the File:

    KalturaUploadedFileTokenResource mediaResource = new KalturaUploadedFileTokenResource();
    mediaResource.Token = uploadToken.Id;
    mediaEntry = client.MediaService.AddContent(mediaEntry.Id, mediaResource);

     

Chunked Video Upload or Upload Pause and Resume Flow

 

The Kaltura API supports an upload pause and resume via chunked upload workflow.

Additionally, Kaltura also provide a jQuery plugin that simplifies the process: https://github.com/kaltura/jQuery-File-Upload

An example showing how to use the jquery plugin can be seen at: https://developer.kaltura.org/recipes/upload

 

Note: For any bulk actions that will create more than 5,000 entries (e.g., users), including categories bulk uploads, please contact your Kaltura representative to coordinate the upload. 

 

If you can’t use the jQuery plugin above, you can implement it yourself by chunking the file and calling the uploadToken service. 

To use the uploadToken service for chunked upload, set the following parameters in the upload action:

  1. resume - should be set to true.
  2. resumeAt – the byte offset to add current chunk to.
  3. finalChunk - should be set to 0 for all chunks, and set to 1 for the last chunk.

For reference example, see https://github.com/kaltura/kaltura-chunked-upload-test

FAQ Type: 
(45103 reads)