Hello,
i configured config.ini and trying to upload using php cli client. configured the adminsecret,serviceurl and partner id and getting a
PHP Fatal error: Uncaught KalturaClientException: Uploading files is not supported with stream context http request, please use curl. in /tmp/php5/KalturaClientBase.php:608
Stack trace: #0 /tmp/php5/KalturaClientBase.php(477): KalturaClientBase->doPostRequest(‘http://cdn-02.h…’, Array, Array) #1 /tmp/php5/KalturaClientBase.php(351): KalturaClientBase->doHttpRequest(‘http://cdn-02.h…’, Array, Array) #2 /tmp/php5/KalturaClient.php(1074): KalturaClientBase->doQueue() #3 /tmp/php5/TestCode/TestMain.php(127): KalturaBaseEntryService->upload(‘DemoVideo.flv’) #4 /tmp/php5/TestCode/TestMain.php(58): TestMain->add() #5 /tmp/php5/TestCode/TestMain.php(145): TestMain::run() #6 {main}
thrown in /tmp/php5/KalturaClientBase.php on line 608
I am following the workflow tutorial, i was able to generate a token id and now trying to send the data usng that id as a next step. I get the following:
KalturaFullClient.min.js:684 Uncaught TypeError: Cannot read property '0' of undefined
at KalturaRequestBuilder.doHttpRequest (KalturaFullClient.min.js:684)
at KalturaRequestBuilder.execute (KalturaFullClient.min.js:694)
at test3.html:26
at Object.success (KalturaFullClient.min.js:690)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at A (jquery.min.js:4)
at XMLHttpRequest.<anonymous> (jquery.min.js:4)
It won’t work. Also, modern browsers will all block:
var fileData = "file:///var/www/html/js/a.flv";
You can use the HTML5 File APIs to read a file but I believe what you really want is for the user to select a file interactively anyhow. If that’s NOT what you want, then maybe you’re better off using the NodeJS client instead?
You can see a full code sample here:
Dependsing on your needs, you may want to consider using https://github.com/kaltura/kaltura-parallel-upload-resumablejs instead. This is a pure JS implementation that utilises https://github.com/23/resumable.js and does not rely on our JS client. It supports uploading several chunks in parallel for faster processing of big flies. It’s FOSS and you’re welcome to use it and make changes to it as you please.
Assuming you do wish to write your own code and interactive I/F using the JS client, here is a fully working, bare bones example. Of course it should not be used exactly as is.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="KalturaClient.min.js"></script>
<script src="KalturaSessionService.min.js"></script>
<script src="KalturaMediaService.min.js"></script>
<script src="KalturaUploadTokenService.min.js"></script>
<script>
function upload() {
var config = new KalturaConfiguration();
config.serviceUrl = 'https://www.kaltura.com';
var client = new KalturaClient(config);
// Note: this is meant only as a sample.
// You should NEVER generate sessions on the client,
// as this exposes your Admin Secret to users.
// Instead, generate a session on the server and pass the
// KS to the client.
KalturaSessionService.start(
"YOUR_ADMIN_SECRET",
"YOUR_USER_ID",
2,
YOUR_PARTNER_ID)
.execute(client, function(success, ks) {
if (!success || (ks.code && ks.message)) {
console.log('Error starting session', success, ks);
} else {
client.setKs(ks);
var uploadToken = {objectType: "KalturaUploadToken"};
KalturaUploadTokenService.add(uploadToken)
.execute(client, function(success, results) {
if (!success || (results && results.code && results.message)) {
console.log('Kaltura Error', success, results);
} else {
console.log('Kaltura Result', results);
var uploadTokenId = results.id;
var resume = false;
var finalChunk = true;
var resumeAt = -1;
KalturaUploadTokenService.upload(uploadTokenId, document.getElementById("fileData"), resume, finalChunk, resumeAt)
.execute(client, function(success, results) {
if (!success || (results && results.code && results.message)) {
console.log('Kaltura Error', success, results);
} else {
console.log('Kaltura Result', results);
var entry = {objectType: "KalturaMediaEntry"};
entry.mediaType = 1 /* KalturaMediaType.VIDEO */;
entry.name = "test";
KalturaMediaService.add(entry)
.execute(client, function(success, results) {
if (!success || (results && results.code && results.message)) {
console.log('Kaltura Error', success, results);
} else {
console.log('Kaltura Result', results);
console.log(results);
var entryId=results.id;
var resource = {objectType: "KalturaUploadedFileTokenResource"};
resource.token = uploadTokenId;
KalturaMediaService.addContent(entryId, resource)
.execute(client, function(success, results) {
if (!success || (results && results.code && results.message)) {
console.log('Kaltura Error', success, results);
} else {
console.log('Kaltura Result', results);
}
});
}
});
}
});
}
});
}
});
}
</script>
<input type="file" id="fileData" name="filedata" />
<input type="button" onclick="upload()" value="Upload to Kaltura" />