Upload videos to the flavour via API


#1

Hi,

what are the API functions to upload a video directly to a Flavour in an entry. I’m not asking about upload content but to upload to the flavour.

Via KMC I get it in Edit Entry -> Flavors -> (Action from a flavour) -> Upload. My question is how to do it via API.

thanks

Lluís


#2

Hello Lluis,

You can use the uploadToken and flavorAsset APIs to do so, here is a code sample using the PHP client:

<?php
$flavor_id = '0_6jen83sq';
$uploadToken = new KalturaUploadToken();
$tokenResult = $client->uploadToken->add($uploadToken);
$tok=$tokenResult->id;
$resume = null;
$finalChunk = null;
$resumeAt = null;
$fileData='/home/jess/vid_file.mp4';
$result = $client->uploadToken->upload($tok, $fileData, $resume, $finalChunk, $resumeAt);
$contentResource = new KalturaUploadedFileTokenResource() ;
$contentResource->token=$tok;
$result = $client->flavorAsset->setContent($flavor_id, $contentResource);
var_dump($result);

#3

Thanks jess! This is the information that we were looking for,

Lluís