Skip to content

Commit a2a01dd

Browse files
committed
Corrections
1 parent 0b37039 commit a2a01dd

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pyclowder/api/v2/datasets.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,20 +361,21 @@ def create_folder(connector, client, datasetid, foldername, parent_folder=None):
361361
parent_folder -- the id of the parent folder, if not provided, the folder will be created at the root of the dataset
362362
"""
363363

364+
logger = logging.getLogger(__name__)
365+
364366
url = posixpath.join(client.host, 'api/v2/datasets/%s/folders' % datasetid)
365367
headers = {"X-API-KEY": client.key,
366368
"Content-Type": "application/json"}
367369

370+
folder_data = {"name": foldername}
368371
if parent_folder is not None:
369-
folder_data = json.dumps({"name": foldername, "parent_folder": parent_folder})
370-
else:
371-
folder_data = json.dumps({"name": foldername})
372+
folder_data["parent_folder"] = parent_folder # Add only if provided
372373

373374
result = requests.post(url, headers=headers, json=folder_data,
374375
verify=connector.ssl_verify if connector else True)
375376
result.raise_for_status()
376377
folder_id = result.json()["id"]
377-
logger.debug("created folder id = [%s]", folder_id)
378+
logger.debug("created folder id = %s", folder_id)
378379
return folder_id
379380

380381

pyclowder/api/v2/files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def upload_multiple_files(connector, client, datasetid, filepaths, folder_id=Non
423423
files = []
424424
for filepath in filepaths:
425425
if os.path.exists(filepath):
426-
files.append(os.path.basename(filepath), open(filepath, 'rb'))
426+
files.append(("files", open(filepath, 'rb')))
427427
else:
428428
logger.error("unable to upload file %s (not found)", filepath)
429429
return None

0 commit comments

Comments
 (0)