Skip to content

Commit 4c7724a

Browse files
committed
Merge branch 'master' into posixpath-joins
2 parents 1e7c35a + 50b6b36 commit 4c7724a

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](https://semver.org/).
77

8+
89
## 3.0.7 - 2023-10-11
910

1011
### Added
1112

1213
- Modified v1 and v2 endpoints to ignore trailing slashes on Clowder host URLs.
1314

15+
- ## 3.0.6 - 2023-10-10
16+
17+
### Added
18+
19+
- Allow folder id to be passed to api/v2 upload_to_dataset
20+
1421
- ## 3.0.5 - 2023-10-09
1522

1623
### Added

pyclowder/api/v2/files.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,15 @@ def upload_thumbnail(connector, client, fileid, thumbnail):
324324
logger.error("unable to upload thumbnail %s to file %s", thumbnail, fileid)
325325

326326

327-
def upload_to_dataset(connector, client, datasetid, filepath, check_duplicate=False):
327+
def upload_to_dataset(connector, client, datasetid, filepath, check_duplicate=False, folder_id=None):
328328
"""Upload file to existing Clowder dataset.
329329
330330
Keyword arguments:
331331
connector -- connector information, used to get missing parameters and send status updates
332332
client -- ClowderClient containing authentication credentials
333333
datasetid -- the dataset that the file should be associated with
334334
filepath -- path to file
335+
folder_id -- the folder that the file should be uploaded to
335336
check_duplicate -- check if filename already exists in dataset and skip upload if so
336337
"""
337338

@@ -349,6 +350,8 @@ def upload_to_dataset(connector, client, datasetid, filepath, check_duplicate=Fa
349350
return _upload_to_dataset_local(connector, client, datasetid, filepath)
350351

351352
url = posixpath.join(client.host, 'api/v2/datasets/%s/files' % datasetid)
353+
if folder_id is not None:
354+
url = '%s?folder_id=%s' % (url, folder_id)
352355

353356
if os.path.exists(filepath):
354357
filename = os.path.basename(filepath)

pyclowder/files.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def upload_thumbnail(connector, host, key, fileid, thumbnail):
254254
return thumbnail_id
255255

256256

257-
def upload_to_dataset(connector, host, key, datasetid, filepath, check_duplicate=False):
257+
def upload_to_dataset(connector, host, key, datasetid, filepath, check_duplicate=False, folder_id=None):
258258
"""Upload file to existing Clowder dataset.
259259
260260
Keyword arguments:
@@ -264,10 +264,11 @@ def upload_to_dataset(connector, host, key, datasetid, filepath, check_duplicate
264264
datasetid -- the dataset that the file should be associated with
265265
filepath -- path to file
266266
check_duplicate -- check if filename already exists in dataset and skip upload if so
267+
folder_id -- the folder that the file should be associated with
267268
"""
268269
client = ClowderClient(host=host, key=key)
269270
if clowder_version == 2:
270-
return files.upload_to_dataset(connector, client, datasetid, filepath, check_duplicate)
271+
return files.upload_to_dataset(connector, client, datasetid, filepath, check_duplicate, folder_id)
271272
else:
272273
logger = logging.getLogger(__name__)
273274

0 commit comments

Comments
 (0)