@@ -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 )
0 commit comments