developmentseed / obstore

Simple, fast integration with Amazon S3, Google Cloud Storage, Azure Storage, and S3-compliant APIs like Cloudflare R2
https://developmentseed.org/obstore
MIT License
146 stars 3 forks source link

Failed to connect to Cloudflare R2 #58

Closed legout closed 3 weeks ago

legout commented 3 weeks ago

I was trying to connect to r2 using the following code:

import boto3
from obstore.store import S3Store

session=boto3.Session(profile_name="r2")
r2=S3Store.from_session(session, bucket="yfin-db")

But I get this error


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[132], line 5
      2 from obstore.store import S3Store
      4 session=boto3.Session(profile_name="r2")
----> 5 r2=S3Store.from_session(session, bucket="yfin-db")

TypeError: 'NoneType' object cannot be converted to 'PyString'
``
kylebarron commented 3 weeks ago

Hmm. Maybe we need to improve the errors here so we know which attribute failed in extraction.

I'm guessing it's possibly this line https://github.com/developmentseed/obstore/blob/eba5019dc896685457f9899ef37124eb50e59f03/pyo3-object_store/src/aws.rs#L74

Can you run

session.region_name

Is that None?

legout commented 3 weeks ago

Yes. session.region_name is None

Adding any region_name to boto3.Session fixed this issue.