Skip to content

Commit 19d70aa

Browse files
committed
add option to pass in folder id
1 parent 48a08ef commit 19d70aa

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pyclowder/api/v2/files.py

Lines changed: 3 additions & 2 deletions
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, folder_id=None, check_duplicate=False):
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

@@ -348,7 +349,7 @@ def upload_to_dataset(connector, client, datasetid, filepath, check_duplicate=Fa
348349
if filepath.startswith(connector.mounted_paths[source_path]):
349350
return _upload_to_dataset_local(connector, client, datasetid, filepath)
350351

351-
url = '%s/api/v2/datasets/%s/files' % (client.host, datasetid)
352+
url = '%s/api/v2/datasets/%s/files?folder_id=%s' % (client.host, datasetid, folder_id)
352353

353354
if os.path.exists(filepath):
354355
filename = os.path.basename(filepath)

0 commit comments

Comments
 (0)