Open
Description
Given the following code:
from cloudpathlib import CloudPath, S3Client
%env AWS_ACCESS_KEY_ID=SCWxxxxxxxxxxxx
%env AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxx
s3_client = S3Client(endpoint_url='https://s3.fr-par.scw.cloud')
bucket = CloudPath('s3://my-scw-bucket-name', client=s3_client)
file = bucket.joinpath('folder/file.txt')
file.read_text(encoding="utf-8") # error!
This will result in the following error:
IsADirectoryError: [Errno 21] Is a directory: '/tmp/tmpcwvt0_jn/my-scw-bucket-name/folder/file.txt'
However, when we also add the region in the mix (by adding %env AWS_DEFAULT_REGION=fr-par
to the header), it works.
The region should probably always be set for s3-compatible storage, but this error is very misleading. Any ways to make this easier to debug?
To be fair, when running the above code with Cloudflare R2, it spits out an 'unsupported region' error on the first operation. Somehow, Scaleway's S3 storage seems to accept some requests with an incorrect region.