0

我一直在尝试通过表单将文件上传到 Amazon S3,但我遇到了一些我不知道如何修复的错误。

有人遇到过这种类型的错误吗?

Heroku log errors:

response => #<Excon::Response:0x00000007294a30 @body="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>

Excon::Errors::Forbidden (Expected(200) <=> Actual(403 Forbidden)

配置/初始化程序/carrierwage.rb

CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider               => "AWS",
    :aws_access_key_id      => ENV['AWS_ACCESS_KEY_ID'],
    :aws_secret_access_key  => ENV['AWS_SECRET_ACCESS_KEY']
  }
  config.fog_directory  = ENV['AWS_S3_BUCKET']
end

应用程序/上传程序/file_uploader.rb

  storage :fog

  include CarrierWave::MimeTypes
  process :set_content_type

  def extension_white_list
     %w(jpg jpeg gif png pdf)
  end

  # Override the directory where uploaded files will be stored.
  # This is a sensible default for uploaders that are meant to be mounted:
  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end                                  

我已经设定

环境。Heroku 上的变量。

我使用美国标准的桶。

4

0 回答 0