gpt4 book ai didi

ruby-on-rails - 缺失区域;使用 :region option or export region name to ENV ['AWS_REGION' ]

转载 作者:数据小太阳 更新时间:2023-10-29 07:12:37 26 4
gpt4 key购买 nike

我知道还有其他相同的问题,但他们没有解决我的问题。

我不断收到错误:Aws::Errors::MissingRegionError in BooksController#create,

缺少区域;使用 :region 选项或将区域名称导出到 ENV['AWS_REGION']。但是,这是我的配置

开发.rb:

config.paperclip_defaults = {
storage: :s3,
s3_host_name: "s3-us-west-2.amazonaws.com",
s3_credentials: {
bucket: ENV['AWS_BUCKET'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
s3_region: ENV['us-west-2']
}

}

生产.rb:

config.paperclip_defaults = {
storage: :s3,
s3_host_name: "s3-us-west-2.amazonaws.com",
s3_credentials: {
bucket: ENV['AWS_BUCKET'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
s3_region: ENV['us-west-2']
}

}

和Application.rb:

config.paperclip_defaults = {
storage: :s3,
s3_host_name: "s3-us-west-2.amazonaws.com",
s3_credentials: {
bucket: ENV['AWS_BUCKET'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
s3_region: ENV['us-west-2']
}

}

但是,它不断出现错误。我从其他问题中听取了其他人的建议。希望有人能帮忙。

最佳答案

您应该将 ENV['AWS_REGION'] 环境变量设置为 "us-west-2" 并将其用作

s3_region: ENV['AWS_REGION']

或者使用字符串:

s3_region: 'us-west-2'

此外,s3_region 选项应该从 config/environments/{development|production} 中移出 credentials 哈希:

config.paperclip_defaults = {
storage: :s3,
s3_host_name: "s3-us-west-2.amazonaws.com",
s3_region: 'us-west-2', # or ENV['AWS_REGION']
s3_credentials: {
bucket: ENV['AWS_BUCKET'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
}
}

关于ruby-on-rails - 缺失区域;使用 :region option or export region name to ENV ['AWS_REGION' ],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41118606/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com