Last active
March 1, 2017 19:46
-
-
Save benlansdell/a66bc54ca0b23a0ecf0c2ace4b92d83a to your computer and use it in GitHub Desktop.
Upload files to Zenodo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
headers = {"Content-Type": "application/json"} | |
r = requests.post("https://zenodo.org/api/deposit/depositions?access_token=ACCESS", data="{}", headers=headers) | |
deposition_id = r.json()['id'] | |
l = len(nevfiles) | |
#for idx,nv in enumerate(nevfiles): | |
for idx in range(31,len(nevfiles)): | |
nv = nevfiles[idx] | |
print("Depositing %d/%d: %s"%(idx+1,l,nv)) | |
data = {'filename': nv} | |
files = {'file': open(nv, 'rb')} | |
r = requests.post("https://zenodo.org/api/deposit/depositions/%s/files?access_token=ACCESS" % deposition_id, data=data, files=files) | |
if r.status_code == 400: | |
print("HTTP bad request, exiting") | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment