Hi,
I am trying to figure out how to upload a video file to CMS by using python, but am constantly getting type image
This is my code:
import requests
import json
url = ‘http://my_ip/api/authorize/access_token’
library = ‘http://my_ip/api/library’
clientId = ‘CLcHDq4WOoUfB9VtNWZeSz1TTV1zya3yu6eYcBqE’
clientSecret = ‘7eemAx8c9PPmFrwPyeAc91RjSc5HzsplpwURXyrNhPMseHcUNJj9d3M0iqOCMCNnWO3tfIgqbx4Ljt8gElJlT4UCYDax6SktryA1qFv6BvnmY34e5bBcAEa6zB1zIHzjaCA44O0vdIAofW73vr8KWlgwoQECotfYqXb1iZrAdAWihsuQqoYEgQgPC0oqhgjNWWc8LyONMjzq26k1FtPINnTwLnX9lPOzIZqYLHOGiMddDv6KTT4c8LRzHFJgWD’
data = {‘grant_type’: ‘client_credentials’}
access_token_response = requests.post(url, data=data, verify=False, allow_redirects=False, auth=(clientId, clientSecret))
tokens = json.loads(access_token_response.text)
print("Bearer " + tokens[‘access_token’])
headers = {‘Authorization’: "Bearer " + tokens[‘access_token’]}
with open(r’C:\Users\test\PycharmProjects\xibo\app\videos\test.mp4’, ‘rb’) as filename:
encoder = {‘Content-Type’: ‘multipart/form-data’, ‘name’: fileName, ‘files’: fileLocation, ‘updateInLayouts’: ‘1’, ‘deleteOldRevisions’: ‘1’} response = requests.post(url, headers=headers, data=encoder)
print(response.text)
{“files”:[{“name”:“my song”,“size”:84158583,“type”:“image”,“url”:"/api/library?file=1568035915-5387&download=1",“width”:null,“height”:null,“mediaId”:809,“storedas”:809,“duration”:10,“retired”:0,“fileSize”:84158583,“md5”:“d108f4e64dba24bc31f9b844937b1150”,“enableStat”:“Inherit”,“delete_url”:"/api/library?file=my%song",“delete_type”:“DELETE”}]}