diff --git a/setup.py b/setup.py index 04720a8..22cb91a 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name = "thirdlight", - version = "0.1.0", + version = "0.2.0", author = "ReThought Ltd", author_email = "code@rethought-solutions.com", url = "https://github.com/Rethought/thirdlight.git", diff --git a/src/thirdlight.py b/src/thirdlight.py index b7ad584..045395c 100644 --- a/src/thirdlight.py +++ b/src/thirdlight.py @@ -194,7 +194,7 @@ def _query(self, **inParams): response = requests.post( self.thirdlight.api_url, data=json.dumps(params), - ).json + ).json() # note some methods return None - such as adding files to # an asynchronous upload. @@ -212,7 +212,7 @@ def connect(self): self.session_key = response.sessionId def upload_image(self, source, folderId=None, folderPath=None, caption="", - keywords=[], block=True): + keywords=[], block=True, extra_meta={}): """Upload image at 'source' to folder with the given folderId and captioned and keyworded accordingly. Asynchronous upload, you get the uploadKey returned. @@ -252,9 +252,19 @@ def upload_image(self, source, folderId=None, folderPath=None, caption="", if folderId is None: folderId = self.resolve_folder_id(folderPath) - response = self.Upload_CreateUpload(params=dict(destination=folderId, - synchronous=False, - lifetime=60)) + edit_md = dict( + caption='OPTIONAL', + keywords='OPTIONAL' + ) + for key in extra_meta: + edit_md.update({key: 'OPTIONAL'}) + + response = self.Upload_CreateUpload(params=dict( + destination=folderId, + synchronous=False, + lifetime=60, + editablemetadata=edit_md + )) uploadKey = response.uploadKey # get the file base64 encoded - we'll look to sort out the big file @@ -272,6 +282,9 @@ def upload_image(self, source, folderId=None, folderPath=None, caption="", "data": b64, "metadata": {'caption': caption, 'keywords': keywords}, } + # Any additional file metadata to include in the upload + if extra_meta: + fileData['metadata'].update(extra_meta) fileData = dict(upload_file=fileData) self.Upload_AddFilesToUpload(uploadKey=uploadKey, fileData=fileData)