0
votes

I am building a web app in Rails 5, Ruby 2.4.0 and using the AWS-SDK Gem along with Shrine gem.

Currently I get this error message when I try to upload an image to my AWS Bucket.

I have verified my region here: http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region

enter image description here

My shrine.rb file:

 require "shrine"
require "shrine/storage/s3"
require "image_processing/mini_magick"

s3_options = {
    :access_key_id =>       ENV["AWS_ACCESS_KEY_ID"],
    :secret_access_key =>   ENV["AWS_SECRET_KEY"],
    :region =>              'ca-central-1',
    :bucket =>              ENV["AWS_BUCKET"],
}

Shrine.storages = {
    cache: Shrine::Storage::S3.new(prefix: "cache", **s3_options),
    store: Shrine::Storage::S3.new(prefix: "store", **s3_options),
}

I hardcoded in the region to see if it was perhaps the an issue with my ENV. but i get the same results.

I am stuck with how to proceed on this, as every time I try to set an endpoint for my region shrine screams and says its an invalid config.

Any assistance here would be greatly appreciated!

2
Go back to the AWS console and verify that you really did create the bucket in ca-central-1.Michael - sqlbot

2 Answers

1
votes

This issue was reported in shrine#163, and the issue seems to be resolved with specifying the :endpoint:

require "shrine"
require "shrine/storage/s3"
require "image_processing/mini_magick"

s3_options = {
  :access_key_id =>       ENV["AWS_ACCESS_KEY_ID"],
  :secret_access_key =>   ENV["AWS_SECRET_KEY"],
  :region =>              'ca-central-1',
  :bucket =>              ENV["AWS_BUCKET"],
  :endpoint =>            ENV["AWS_ENDPOINT"] # <=======
}

Shrine.storages = {
  cache: Shrine::Storage::S3.new(prefix: "cache", **s3_options),
  store: Shrine::Storage::S3.new(prefix: "store", **s3_options),
}
0
votes

Add another param:

:s3_host_name => s3.ca-central-1.amazonaws.com