I am new to Pyhton/Kaltura api, trying to upload videos on to their platform. I have a simple Flask application with the code below.
from flask import Flask
from KalturaClient import *
from KalturaClient.Plugins.Core import *
import os
app = Flask(__name__)
config = KalturaConfiguration(partner_id)
config.serviceUrl = "https://www.kaltura.com/"
client = KalturaClient(config)
ks = client.session.start(
"some_secret",
"username@user.com",
KalturaSessionType.ADMIN,
'client-id')
client.setKs(ks)
uploadToken = KalturaUploadToken()
uploadTokenId = "upload id"
fileData = open('/path/to/file', 'r')
resume = False
finalChunk = True
resumeAt = -1
client.uploadToken.upload(uploadTokenId, fileData, resume, finalChunk, resumeAt)
# print(result);
entry = KalturaMediaEntry()
entry.mediaType = KalturaMediaType.VIDEO
entry.name = "going home 6"
entry.description = "none"
client.media.add(entry)
# print(result);
entryId = "entry_id"
resource = KalturaUploadedFileTokenResource()
resource.token = "sometoken"
result = client.media.addContent(entryId, resource)
print(result)
if __name__ == '__main__':
app.run(debug=True)
I am following Kaltura API Workflow in order to upload a simple video to my Kaltura dashboard. I can follow the work flow on Kaltura console but cannot replicate the process in Flask. When I run the code, I am getting the error below
File “app.py”, line 26, in
client.uploadToken.upload(uploadTokenId, fileData, resume, finalChunk, resumeAt)
File “/Users/dsingh/.virtualenvs/Kaltura_API/lib/python3.6/site-packages/KalturaClient/Plugins/Core.py”, line 61905, in upload
resultNode = self.client.doQueue()
File “/Users/dsingh/.virtualenvs/Kaltura_API/lib/python3.6/site-packages/KalturaClient/Client.py”, line 340, in doQueue
postResult = self.doHttpRequest(url, params, files)
File “/Users/dsingh/.virtualenvs/Kaltura_API/lib/python3.6/site-packages/KalturaClient/Client.py”, line 293, in doHttpRequest
url, params, files, self.requestHeaders, requestTimeout)
File “/Users/dsingh/.virtualenvs/Kaltura_API/lib/python3.6/site-packages/KalturaClient/Client.py”, line 275, in openRequestUrl
e, KalturaClientException.ERROR_CONNECTION_FAILED)
KalturaClient.Base.KalturaClientException: ‘utf-8’ codec can’t decode byte 0x85 in position 26: invalid start byte (-4)