我在我的Rails (4.2)应用程序中使用剪纸夹进行S3图像上传。一切都很好,除了image_tag不显示图像而是显示图像的标题这一事实。我遗漏了什么?
recipe.rb
class Recipe < ActiveRecord::Base
has_attached_file :image, styles: {
thumb: '100x100>',
square: '200x200#',
medium: '300x300>'
}
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
validates_with AttachmentSizeValidator, attributes: :image, less_than: 1.megabytes
end配方show.html.erb
<p id="notice"><%= notice %></p>
<p>
<strong>Name:</strong>
<%= @recipe.name %>
</p>
<div class="col-xs-12" style="height:400px">
<%= image_tag @recipe.image.url(:original) %>
</div>
<%= link_to 'Edit', edit_recipe_path(@recipe) %> |
<%= link_to 'Back', recipes_path %>更新:解决方案
要使它发挥作用,需要两件事:
s3_host_name: "s3-#{ENV['AWS_REGION']}.amazonaws.com"添加到配置中。正如建议的这里那样,这是一个解决方案。:s3_protocol => :https添加到配置中,因为aws-sdk-2需要这一点(如注释中提到的)。发布于 2018-01-03 17:45:18
在aws-adk-2中,您需要在配置s3 => :https中显式指定:s3_protocol协议。
最新版本的回形针依赖于aws-sdk-2。所以你必须指定协议。
以这种方式,这将节省您的图像URL与https。
这将帮助您请参阅链接。你也有同样的问题。
https://stackoverflow.com/questions/48079602
复制相似问题