Does cloudflare R2 supports python s3fs? is it only supports s3 apis?

hi,

I am able connect s3 compatible storage like minio with python s3fs which helps to read and write files object as local system, but not able get results after connecting R2, so my question is does this have constraint on supporting this?
(S3Fs is a Pythonic file interface to S3. It builds on top of [botocore]).

from s3fs import S3FileSystem
s3 = S3FileSystem(key="", secret="", client_kwargs={'endpoint_url': 'https://{account_id}.r2.cloudflarestorage.com'})
s3.ls('s3://{bucket_name}/path/smapletest.jpg')

I had the same problem and figured out to get s3fs working with r2-storage, one have to add additional parameters.

import s3fs

fs = s3fs.S3FileSystem(
  key="some_key", 
  secret="some_secret", 
  client_kwargs=dict(endpoint_url="https://123456.r2.cloudflarestorage.com"), 
  s3_additional_kwargs=dict(ACL="private") # <- this is necessary for working properly with r2. 
) 
1 Like