Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix URL when bucket is contained in endpoint #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SplittyDev
Copy link

@SplittyDev SplittyDev commented Jun 17, 2023

ZitaneLabs

TL;DR

This fixes a bug1 where the URL is constructed incorrectly in the case that the S3 host/endpoint already contains the bucket name in the URL and path-style URLs are enabled.

Example

Cloudflare R2 storage specifies an URL such as this:
https://12345foo.r2.cloudflarestorage.com/my-bucket

Since the bucket is specified in the URL given by Cloudflare, but also added at the end of the endpoint, this results in requests failing with 400 Bad Request.

What we did

We fixed this simply by checking whether the host ends in /{bucket_name}, and skipping inclusion of the bucket at the end if that's the case. We also added a test case to make sure the behavior works correctly and doesn't regress.

Footnotes

  1. I'm actually not 100% sure this is really a bug, but this fix makes life easier, especially for R2 users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant