简体   繁体   中英

Rails 4, Paperclip, S3 wrong url path

My heroku + Rails 4 + paperclip w/ AWS s3 is generating the wrong path for the image file.

This is the url paperclip is generating...

http://s3.amazonaws.com/travelquotesys/companies/logos/000/000/001/original/index.jpg%3F1416856406

It should be

http://s3.amazonaws.com/travelquotesys/companies/logos/000/000/001/original/index.jpg?1416856406

For some odd reason paperclip is generating the %3F instead of ? I don't know why it does that. I have a few Apps running on Heroku and this is the only one with this problem.

Your issue is related to a recent commit which doesn't properly escape the timestamp. A temporary workaround is to disable the timestamp while a fix is worked-out.

company.logo(:original, timestamp:false) # or whatever style you're using

Or you can disable this globally by putting the following line within your config/initializers/paperclip.rb file .

Paperclip::Attachment.default_options[:use_timestamp] = false

The issue is that Paperclip is escaping the url, so the character ? is escaped to %3F . To solve this issue add the following option to the S3 configuration:

escape_url: false

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM