From f252fdf8a98c3c7ead02e5c25685706aba6d0689 Mon Sep 17 00:00:00 2001 From: Oliver Hilton Date: Mon, 4 Nov 2013 11:18:59 +0000 Subject: [PATCH 1/3] allow additional custom metadata in uploads --- setup.py | 2 +- src/thirdlight.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 04720a8..72fc28c 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name = "thirdlight", - version = "0.1.0", + version = "0.1.1", 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..da0e577 100644 --- a/src/thirdlight.py +++ b/src/thirdlight.py @@ -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. @@ -272,6 +272,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) From 295ef334349f322240ac135ac8c5475a259d8d59 Mon Sep 17 00:00:00 2001 From: Oliver Hilton Date: Mon, 4 Nov 2013 15:28:52 +0000 Subject: [PATCH 2/3] pass through any metadata keys in the create upload method --- setup.py | 2 +- src/thirdlight.py | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 72fc28c..8226e88 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name = "thirdlight", - version = "0.1.1", + version = "0.1.2", 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 da0e577..332795a 100644 --- a/src/thirdlight.py +++ b/src/thirdlight.py @@ -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 From 0fca8c3a6d633a95ff7ff527c2de6aed0e127045 Mon Sep 17 00:00:00 2001 From: ojhilt Date: Tue, 15 Apr 2014 11:36:10 +0100 Subject: [PATCH 3/3] make compatible with new requests package --- setup.py | 2 +- src/thirdlight.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 8226e88..22cb91a 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name = "thirdlight", - version = "0.1.2", + 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 332795a..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.