Skip to content

Commit

Permalink
Merge pull request #207 from shoeffner/fix-form-data
Browse files Browse the repository at this point in the history
Fix handling of empty metadata when uploading data files
  • Loading branch information
JR-1991 authored Jul 26, 2024
2 parents d2c890b + eaead23 commit 0e40e0b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pyDataverse/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1847,9 +1847,10 @@ def upload_datafile(self, identifier, filename, json_str=None, is_pid=True):
url += "/datasets/{0}/add".format(identifier)

files = {"file": open(filename, "rb")}
return self.post_request(
url, data={"jsonData": json_str}, files=files, auth=True
)
metadata = {}
if json_str is not None:
metadata["jsonData"] = json_str
return self.post_request(url, data=metadata, files=files, auth=True)

def update_datafile_metadata(self, identifier, json_str=None, is_filepid=False):
"""Update datafile metadata.
Expand Down

0 comments on commit 0e40e0b

Please sign in to comment.