AWS S3 Bucket Endpoint失败

时间:2017-05-19 02:43:37

标签: ruby-on-rails amazon-web-services amazon-s3 shrine

我正在使用Rails 5,Ruby 2.4.0构建一个Web应用程序,并使用AWS-SDK Gem和Shrine gem。

目前,当我尝试将图片上传到AWS Bucket时,我收到此错误消息。

我在此处验证了我的区域:http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region

enter image description here

  

我的shrine.rb文件:

 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),
}

我在该地区硬编码,看看它是否可能是我的ENV问题。但我得到了相同的结果。

我仍然坚持如何继续这样做,因为每次我尝试为我的区域设置一个端点shrine screams并说它是无效的配置。

非常感谢任何帮助!

2 个答案:

答案 0 :(得分:1)

shrine#163报告了此问题,指定: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),
}

答案 1 :(得分:0)

添加另一个参数:

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