我已经使用carrierwave,fog和Amazon S3成功实现了图片上传。在我的imageuploader中我只使用雾作为存储。但是当我检查我的数据库时,我可以看到只写了文件名而不是亚马逊网址。在我看来,它从aws正确获取没有任何问题。
它应该是这样的吗? 如果是这样,应用程序如何找出s3的确切网址?
imageuploader.rb`
# encoding: utf-8
class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
include CarrierWave::MiniMagick
#Include the sprockets-rails helper for Rails 4+ compatibility:
include Sprockets::Rails::Helper
storage :fog
version :index_size do
process :resize_to_fill => [258, 173]
end
version :thumb_size do
process :resize_to_fill => [100, 100]
end
def extension_white_list
%w(jpg jpeg gif png)
end
end
答案 0 :(得分:0)
您的配置包含存储桶名称,数据库具有文件名。这些是构建文件名实际需要的两条信息(并且可以在没有其他API调用的情况下完成)。网址实际上非常规则,因此服务器执行此操作相当简单。希望有所帮助!