We have a custom PHP application that is currently using the Kaltura Simple Uploader (KSU) but we’ve been asked to convert it in order to get away from using Flash.
I’ve been following the documentation that I’ve found on https://developer.kaltura.com/workflows/Ingest_and_Upload_Media and am using the jQuery File Upload widget so that we can do the chunked and pause/play easily. I’ve got the file uploading but then it prints out to the console “Next, call the media.add and media.addContent API actions to create your Kaltura Media Entry and associate it with this newly uploaded file. Once media.addContent is called, the transcoding process will begin and your media entry will be prepared for playback and sharing. Use the Kaltura JS client library or call your backend service to execute media.add and media.addContent passing the uploadTokenId.”
I’ve tried multiple ways to execute the media.add and media.addContent but I’m hitting a dead end with no errors being returned and nothing extra printing in the console.
Wondering if anyone has successfully integrated this in their application and if so if there are any good examples out there that would help me.
I’m not sure I understand the exact situation. When trying to upload a file using the interactive tutorial here https://developer.kaltura.com/workflows/Ingest_and_Upload_Media, does it work? If it does not, please open your browser’s dev tools and check for errors under the “Console” tab as well as for failing requests under the “Network” tab.
If it works from the interactive web I/F but fails from your own code, please provide the full code and I’ll take a look.
Thanks, yes the workflow interactive tutorial works fine for me if I put in all the info there and try to follow along.
I then decided to try to not even use the jQuery chunked library and just try to follow along the workflow and use the PHP API for everything and I can get the token created and then when I attempt to attach the file to the token I get the error “Upload failed”. I’m not sure if it is not liking the format of the file, as it doesn’t document very well what format the function in the API is expecting the file to be. I’ve tried passing a string of the name, the full path to the file, an actual stream with the file contents and they all give me that same error.
I know that this step works as I’m getting a valid value for the TokenId:
$result = $client->uploadToken->add($uploadToken);
$uploadTokenId = $result->id;
But then I attempt to get the file from the html form input and do this and this is when it fails:
$resume = false;
$finalChunk = true;
$resumeAt = -1;
When using the PHP client, $fileData should be a string set to the full path of your media file.
You can look at this example here:
It’s not exactly what you want since it obtains a blob created by the MediaRecord API, saves that to the disk and then uploads it to Kaltura but it should be enough for you to get the general idea.
That said, if you use https://github.com/kaltura/kaltura-parallel-upload-resumablejs you wouldn’t need the intermediate PHP code that saves the file on the server’s disk and then makes the needed API calls to upload it to the Kaltura server, it can all be done on the client side. In fact, that’s also what I’ve done in the webrtc-krecord repo I provided above, upload_to_kaltura.php is from an earlier iteration and is no longer used.
Are you sure $fileData contains a valid path on disk?
I recommend creating a PHP snippet that accepts the file path as the first arg and makes all the needed requests and executing it from a shell on that server. Let’s see how that goes. If that too fails, it will still be easier to debug than a flow that involves submitting a form in browser context, if it succeeds then at least you’ve isolated the issue.
Can I ask one other question…I’ve got this working but I’ve had to hardcode the ServiceUrl into the code instead of pulling from my config file. If I try pulling from the config by doing the following I get an error “'failed to unserialize server result”:
$config = new KalturaConfiguration($partnerID);
$config->serviceUrl = $serviceUrl;
$config->format = KalturaClientBase::KALTURA_SERVICE_FORMAT_PHP;
$client = new KalturaClient($config);
Do you know why I would get that error if reading from a config file vs hardcoding the exact same value in the $config->serviceUrl variable above?
Without looking at the actual code and config files, I’m afraid I can’t help you spot the issue…
I’m guessing it may have to do with the carriage return and UNIX/Linux vs Windows [\r\n vs \n] or else there’s some other trailing char there but it’s only a guess.
I can also recommend is that you edit:
KalturaClientBase.php so that, right before:
$result = curl_exec($ch);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
Then run it from the shell and see exactly what the request looks like and compare it with what it looks like when you use a literal string when setting $config->serviceUrl
Thanks so much for helping me figure this out! Also it would be nice to know if the ServiceUrl is something that we should be keeping out of git for security reasons or if we can’t figure this out if it is ok keeping it hardcoded directly for now.