相关疑难解决方法(0)

301 S3上传后永久移动

我试图使用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)

ruby amazon-s3 carrierwave fog ruby-on-rails-3.2

12
推荐指数
1
解决办法
2万
查看次数

标签 统计

amazon-s3 ×1

carrierwave ×1

fog ×1

ruby ×1

ruby-on-rails-3.2 ×1