Skip to content

Commit

Permalink
Fix thumbnail upload for v1 files
Browse files Browse the repository at this point in the history
  • Loading branch information
max-zilla authored and robkooper committed Sep 27, 2023
1 parent 25c3e4d commit 946e56b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/)
and this project adheres to [Semantic Versioning](https://semver.org/).

## 3.0.3 - 2023-08-29
## 3.0.4 - 2023-09-27

### Fixed

- Fixed host bug on v1 file thumbnail endpoint.
-
- ## 3.0.3 - 2023-08-29

### Added

Expand Down
6 changes: 3 additions & 3 deletions pyclowder/api/v1/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,18 +295,18 @@ def upload_thumbnail(connector, client, fileid, thumbnail):
"""

logger = logging.getLogger(__name__)
url = client.host + 'api/fileThumbnail?key=' + client.key
url = '%s/api/fileThumbnail?key=%s' % (client.host, client.key)

# upload preview
with open(thumbnail, 'rb') as inputfile:
result = connector.post(url, files={"File": inputfile}, verify=connector.ssl_verify if connector else True)
thumbnailid = result.json()['id']
logger.debug("thumbnail id = [%s]", thumbnailid)

# associate uploaded preview with orginal file/dataset
# associate uploaded preview with original file/dataset
if fileid:
headers = {'Content-Type': 'application/json'}
url = client.host + 'api/files/' + fileid + '/thumbnails/' + thumbnailid + '?key=' + client.key
url = '%s/api/files/%s/thumbnails/%s?key=%s' % (client.host, fileid, thumbnailid, client.key)
connector.post(url, headers=headers, data=json.dumps({}), verify=connector.ssl_verify if connector else True)

return thumbnailid
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='pyclowder',
version='3.0.3',
version='3.0.4',
description='Python SDK for the Clowder Data Management System',
long_description=long_description,

Expand Down

0 comments on commit 946e56b

Please sign in to comment.