caltechlibrary / caltechdata_api

Python library for using the CaltechDATA API
Other
10 stars 3 forks source link

Error trying to use example notebook to upload data #8

Closed Munfred closed 3 years ago

Munfred commented 3 years ago

Hello I'm having trouble getting the example notebook to work, I updated to the latest version of the API.

I'm trying to use the example below. Also, I couldn't find documentation on the arguments the function caltechdata_write. I even looked at the source code but it didn't have many comments so I'm kinda lost

from caltechdata_api import download_file, caltechdata_write
import json
#Now write a file to CaltechDATA test instance (cd-sandbox.tind.io)

token = 'TOKEN'

metaf = open('example43.json', 'r')
metadata = json.load(metaf)
filen = 'logo.gif'

production = False

response = caltechdata_write(metadata, token, filen, production, schema='43')
print(response)

image

tmorrell commented 3 years ago

What’s the size of the file? We might have to switch out the upload method

Munfred commented 3 years ago

2GB

tmorrell commented 3 years ago

Oh, you need to use a real token instead of the placeholder TOKEN value. You can get a CaltechDATA token by following the instructions at https://libanswers.caltech.edu/faq/211307

I've added an exception to make this a bit clearer, but I still need to do some improvements to the S3 upload #3