Created
February 7, 2012 13:38
-
-
Save Hampei/1759709 to your computer and use it in GitHub Desktop.
interpolation for the url when storing paperclip attachments on s3 that works independent of where your bucket is located.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# normally paperclip uses the server/bucket/location format, but that breaks when you have a eu bucket. | |
# This one works for all buckets. | |
# put in an initializer (or somewhere else) and add this to has_attached_file params | |
# :url => ':s3_url', | |
Paperclip.interpolates(:s3_url) { |attachment, style| | |
"#{attachment.s3_protocol}://#{attachment.bucket_name}.s3.amazonaws.com/#{attachment.path(style).gsub(%r{^/}, "")}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment