0

I've been trying to upload files to Amazon S3 through a form, but I'm getting some errors I do not know how to fix.

Does somebody have experience this type of errors?

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)

config/initializers/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

app/uploaders/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                                  

I have set

the env. variables on Heroku.

I'm using the US standard for the bucket.

evanx
  • 1,291
  • 4
  • 17
  • 33

0 Answers0