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

AWS public_url missing region when using non default region #2523

Closed
AnrichVS opened this issue Dec 3, 2020 · 0 comments
Closed

AWS public_url missing region when using non default region #2523

AnrichVS opened this issue Dec 3, 2020 · 0 comments

Comments

@AnrichVS
Copy link

AnrichVS commented Dec 3, 2020

Hi,

Please see changes made here - #2439

This doesn't account for cases where valid_subdomain is true, and this code is executed:

if valid_subdomain
  s3_subdomain = @uploader.fog_aws_accelerate ? "s3-accelerate" : "s3"
  "#{protocol}://#{@uploader.fog_directory}.#{s3_subdomain}.amazonaws.com/#{encoded_path}"
else
...

This generates an invalid URL if your bucket isn't in the default region.

The fix (I'll make a pull request if if I can find time) -

region = @uploader.fog_credentials[:region].to_s
# if directory is a valid subdomain, use that style for access
if valid_subdomain
  s3_subdomain = if @uploader.fog_aws_accelerate
                                "s3-accelerate"
                              else
                                (region =='' || region == DEFAULT_S3_REGION) ? 's3' : "s3.#{region}"
                              end
  "#{protocol}://#{@uploader.fog_directory}.#{s3_subdomain}.amazonaws.com/#{encoded_path}"
else
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants