我试图使用carrierwave和雾宝石将图像上传到Ruby on Rails上的S3,正确上传图像但是当我尝试保存包含刚刚上传的图像信息的模型时我得到了这个错误:
Excon::Errors::MovedPermanently in UserController#show
app/models/user.rb:46:in `process_image_with_key'
app/controllers/user_controller.rb:12:in `show'
<Excon::Response:0x007f97846a3c18 @body="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>PermanentRedirect</Code><Message>The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.</Message>
Run Code Online (Sandbox Code Playgroud)
用户模型:
mount_uploader :image, AvatarUploader
def image_name
File.basename(image.path || image.filename) if image
end
def process_image_with_key( key )
unless key.nil?
self.key = key
self.remote_image_url = self.image.direct_fog_url(with_path: true)
self.save!
end
end
Run Code Online (Sandbox Code Playgroud)
AvatarUploader:
# encoding: utf-8
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWaveDirect::Uploader
include CarrierWave::RMagick
# Include the Sprockets helpers …Run Code Online (Sandbox Code Playgroud)