Please help out here
Please help out here.
So I have moved alot of our data from S3 to using R2.
Now everything is working, on django I have made a custom storage class, and some models are using it.
While everything is working there is one small issue.
I am trying to get the file size but when I try to get the file size I get the 400 head object error. And this happens on the endpoint url and not on the custom domain. How to force botocore to use the custom domain, else where its using custom domain as it is...so why here.
16 Replies
I want to force botocore to use the custom domain
anyone?
Are you trying to access the S3 API via the custom domain?
If so, that isn’t supported. A custom domain only opens up read-only access to your bucket to the public.
You’ll have to use the r2.cloudflarestorage.com domain for the S3 API
So then why would we be getting a 400 Head object error when calling the the size of the file why would this happen.
Interestingly locally when I try it on my laptop I dont get such an error
Because HeadObject is an S3 command. If you visit custom domain.com/path/to/object, you should be able to see your object. This is the only operation that custom domains support at the moment
Check if you’re actually hitting the custom domain?
I am hitting the non custom domain on production as well
is this connected to cors by any chance?
Oh I think I may have misunderstood your problem then.
You say this is Python, so I assume it isn’t running in a browser, so it is unlikely that this is CORS.
So you’re getting a 400 on HeadObject to the endpoint <account-id>.r2.cloudflarestorage.com? Does the error have any other details in it that say why it is failing?
no...
I just get this error
All I want is the size of the object, any idea how to curl it manually?
not able to figure out how to authorise it
The 400 response’s HTTP body should have details.
What is your account ID?
cf2bede0326231f6f2e51abc82a027e7
Okay so I've just checked your logs and it looks like you were getting a 404 when you sent a HEAD request to your custom domain. That won't work like I said, but I don't see any 400s.
Can you show me the entirety of your program? (the relevant bits at least), just redact your credentials. Keep the endpoint URL in there if possible
wait ...
give me second
can you check?
I just sent a 400 request
@sdnts ^
Are you setting your region name to
ap-south-1
? That isn't a valid name
The response should have told you, your problem is this:
The region name 'ap-south-1' is not valid. Must be one of: wnam, enam, weur, eeur, apac, auto
Oh...botocore is doing this
I try to get the image.size
Yeah so best set it to
auto
due to which this happens
ok
thanks alot!!
It worked
Nice!