Sample Endpoint Application

How do I upload a file to ClearSlide and receive updates on its status?

The python script below uses both the upload APIs in order to upload a file from your local machine to ClearSlide and to receive updates on its upload status.

import sys
import os
import requests
import time
from mimetypes import MimeTypes
import urllib
import json
authURLBase = ''
authURLPath = '/upload'
authURL = authURLBase + authURLPath

print "authURL = " + authURL;

# Absolute path of the file to be uploaded nneds to be provided as an argument while executing this python script
filePathAndName = sys.argv[1]
fileName = filePathAndName.split('/')[-1]
fileSize = os.stat(filePathAndName).st_size
authHeaders = {'authorizationToken':'940a1464-fbbf-43e2-b683-1c8eb3a2552c', 'accept':'application/vnd.api+json',  'Content-Type':'application/json'}
postDataString = "{'data': {'type': 'upload',    'attributes': {      'fileName': "+fileName+", 'fileSize':"+str(fileSize)+"  }  }}" 
print "postDataString = "+postDataString
res =, data=postDataString,headers=authHeaders).json()

print json.dumps(res, indent=4);

# Use postParams and postURL from the response of upload file credentials API
postParams = res['data']['attributes']['postParams']
postURL = res['data']['attributes']['postURL']

mime = MimeTypes()
url = urllib.pathname2url(filePathAndName)
mimeType = mime.guess_type(url)
files = [('file',(fileName, open(filePathAndName, 'rb'), mimeType))]
uploadRes =, data=postParams, files=files)
print "uploadRes = "
print uploadRes

# Use uploadID from the response of upload file credentials API
uploadID = res['data']['id']
statusPath = '/' + uploadID
statusURL = authURL + statusPath

print "statusURL = " + statusURL; 

isComplete = False
while not isComplete:
  statusResult = requests.get(statusURL, headers=authHeaders).json()
  print 'statusResult' 
  print json.dumps(statusResult, indent=4);
  isComplete = statusResult['data']['attributes']['isComplete']

How do I run this python script?

You will need to provide the absolute path of your local file and your target user id in order to upload a file to ClearSlide as shown in the code snippet below.

python ./ /Users/name/Desktop/test.png