Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

expiring_url does not use s3_host_alias #2196

Closed
anark opened this issue May 6, 2016 · 4 comments
Closed

expiring_url does not use s3_host_alias #2196

anark opened this issue May 6, 2016 · 4 comments

Comments

@anark
Copy link

anark commented May 6, 2016

When using paperclip with :url => ":s3_alias_url" and a s3_host_alias set the expiring_url does not use the s3_host_alias.

This really makes a difference when using cloudfront with paperclip. It would be great to be able to offer expiring url's that used the cloudfront endpoint instead of the direct s3 endpoint.

@marcelrouw
Copy link

I ran into the same issue.
Is there a fix or a work around?

@sudara
Copy link

sudara commented Jan 29, 2017

This config in the default or per-model options fixes it for me:

s3_url_options: { virtual_host: true }

This is changed behavior from version 4, but not specified in docs or the upgrade guide.

Old paperclip didn't use the s3_host_alias in the expiring_url, but

  1. It defaulted to http urls (vs. https) and
  2. The way it did signing allowed you to do something like expiring_url.gsub('s3.amazonaws.com/','') to get an url on your CNAME.

After reading some code, it seems that paperclip 5.x merges in s3_url_options to the options it sends s3 presigner. The presigner has an option to use the virtual host (which will force http). See http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Presigner.html#presigned_url-instance_method or the change in implementation here: sudara/alonetone@d227614

@anark
Copy link
Author

anark commented Feb 8, 2017

Even with
s3_url_options: { virtual_host: true }

the
attachment.expiring_url

still give the s3 url instead of using the alias url for me.

@sidraval
Copy link
Contributor

Thank you for reporting this. Unfortunately, we will be deprecating Paperclip and therefore will not have the bandwidth to address this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants