custom uploader

10 replies [Last post]
Joined: 05/06/2009
Points: 29

Hi all

We're building a custom widget using the code from the simple editor.

As part of this we are including a module that will allow us to upload a file to the server, which we will then add to the timeline. The module will be built using api v3.

I'm trying to work out the workflow of an upload. So far i have

1. upload file
media service - upload(fileData)
returns xml containing a filetoken

2. add the entry details and the entry to the server
addfromuploadedfile(KalturaMediaEntry kme, String filetoken)
kme contains details like file name tags etc..
returns xml containing the entryId

Have I missed anything?

I'll post back our experience here as we move along.

Joined: 03/29/2009
Points: 764

Sounds exciting! Seems to me you have the right flow.

Joined: 05/06/2009
Points: 12

I'm working with Cormac on this, getting some unexpected behaviour, the media.upload API3 service is returning the html code for the server front page. Any suggestions?

Update: Solved

public var partnerservices2URL : String = "/index.php/partnerservices2/";

public var partnerservices3URL : String = "/api_v3/";

Unlike the api_v2 urls I had to drop the "/index.php"

Joined: 05/06/2009
Points: 12

We're defining the api-3 services calls in the service locator.

api-2 services are defined like this:

<mx:HTTPService id="getUIConfService" url="{domain}{partnerservices2URL}getuiconf"
        method="POST" resultFormat="e4x"/>

for the api-3 you should define it like so.
<mx:HTTPService id="addfromuploadedfile" url="{domain}{partnerservices3URL}"
        method="GET" resultFormat="e4x" >

Ensure that the method type is GET not POSTand define the service method as a param that gets passed to the service

params.service = "media";
params.action =  "addfromuploadedfile"

etc

Can one of the core team confirm this information :)

Joined: 01/05/2009
Points: 1697

You already have a complete client library for Flex that provide encapsulated implementation of all the Kaltura API in Flex (upload being one of them, but you really should prefer using the KUpload widget for upload, that way you get a more complete upload mechanism).

This is the start of what I'm working on to make clients and client-server flow more visible and easy to understand -
http://www.kaltura.org/kaltura-api-and-testme-console-introduction (based on the contribution of the valuable member Chris Hocking).
http://www.kaltura.org/kaltura-api-client-libraries-guide .

Joined: 05/06/2009
Points: 29

Thanks for the help

Is there any chance you could post a very quick example of how to make a call using the flex client.

So far I'm

1. creating a KalturaConfig object and setting some parameters

var kc:KalturaConfig = new KalturaConfig();
kc.ks = _model.ks;
kc.partnerId = _model.partner_id;
kc.srvUrl = _model.host;

2. creating a KalturaClient object using the config object

var kcl:KalturaClient = new KalturaClient(kc);

then i'm getting a bit stuck, I've tried creating a KalturaCall object and passing that to the post method in KalturaClient like so

var kca:KalturaCall = new KalturaCall();
                        kca.service = "media";
                        kca.action = "addfromuploadedfile";
                        var kme:KalturaMediaEntry = new KalturaMediaEntry();
                        kme.name = "test";
                        kca.setRequestArgument("mediaEntry", kme);
                        var kca_new:KalturaCall = kcl.post(kca);

but nothing happens

any help would be greatly appreciated

Joined: 05/06/2009
Points: 12

Maybe a very simple Flex project that implemented the kcl_Flex is what's needed.

Joined: 05/06/2009
Points: 12

Your using the KalturaCall class directly which is incorrect, KalturaCall is the parent class for the service commands

try this

        var kc:KalturaConfig = new KalturaConfig();
        kc.ks = _model.ks;
        kc.partnerId = _model.partner_id;
        kc.srvUrl = _model.host;
        var kcl:KalturaClient = new KalturaClient(kc);
        var kme:KalturaMediaEntry = new KalturaMediaEntry();
        var kca:MediaAddFromUploadedFile = new MediaAddFromUploadedFile(kme, _model.fileUploadToken);

        kca.addEventListener(KalturaEvent.COMPLETE, onComplete_kca);
        kca.addEventListener(KalturaEvent.FAILED, onFailed_kca);

        kca.execute();

It might be helpful if the KalturaCall throw an error from its execute method, as currently if fails silently

Joined: 05/06/2009
Points: 29

ok so i have a few flex api v3 calls up and running now,

AddFromUploadedFile, MixingGet :)

I've run into a problem when calling the MixingUpdate command

I call in the same way as i do the others

/*
Create the MixingUpdate command to update our Kaltura MixEntry
*/

var kme:KalturaMixEntry = new KalturaMixEntry();
kme.name = "new name";
kme.dataContent = _model.kMixEntry.dataContent;

var mu:MixingUpdate = new MixingUpdate(_model.kMixEntry.id, kme);
mu.config = _model.kConfig;

/*
add this as a listener for events fired by the MixingUpdate command
*/

mu.addEventListener(KalturaEvent.COMPLETE, onComplete_mu);
mu.addEventListener(KalturaEvent.FAILED, onFailed_mu);

/*
fire the command
*/

mu.execute();

the call is failing however with the following error message

The property "KalturaMixEntry::hasRealThumbnail" cannot be updated

Initially when updating i was trying to send the full KalturaMixEntry I had stored in the model but I was getting a "partnerId cannot be updated" message

So I created a blank KalturaMixEntry to send to the server with the name field changed to test it

so... the question is how do i stop this hasRealThumbnail property from getting sent?

ps: is this field deprecated? by removing it from the KalturaMixEntry value object , the MixingUpdate call works

Joined: 05/06/2009
Points: 12

What api-3 service call relates to the api-2 service call loadEntryMultirequest, from the simple editor LoadEntryMRCommand, is it baseEntry:get or mixing:get

Joined: 01/05/2009
Points: 1697

loadEntryMultirequest is an internal command within the CVF that the KSE uses.
The loadEntryMultirequest command calls getEntry, getKshow (deprecated in api_v3) and a getEntries (that retrieve a list of entries inside the Mix) using a single API callback: multirequest that enable creating a sequential series of API calls wrapped in a single API call.

Follow the client library project page - we will soon update with some documents and samples.