简体   繁体   English

Rails 4,回形针,S3错误的URL路径

[英]Rails 4, Paperclip, S3 wrong url path

My heroku + Rails 4 + paperclip w/ AWS s3 is generating the wrong path for the image file. 带AWS s3的我的heroku + Rails 4 +回形针为图像文件生成了错误的路径。

This is the url paperclip is generating... 这是网址回形针正在生成...

http://s3.amazonaws.com/travelquotesys/companies/logos/000/000/001/original/index.jpg%3F1416856406 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 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 ? 出于某种奇怪的原因,回形针正在生成%3F而不是? 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. 我在Heroku上运行了一些应用程序,这是唯一有此问题的应用程序。

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 . 或者,您可以通过将以下行放在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 . 被转义到%3F To solve this issue add the following option to the S3 configuration: 要解决此问题,请在S3配置中添加以下选项:

escape_url: false

Hope it helps! 希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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