Ruby Rails 上的应用程序无法查询 AWS - 错误 403 禁止
Ruby on Rails app can't query AWS - error 403 forbidden
我去年参加了开发 RoR 应用程序的课程。我开发了一个使用我的账户密钥和 returns 结果搜索 AWS 的工具。现在,每当我搜索亚马逊时,我都会收到 403 错误。
我重新创建了我的密钥,并在 Rails 控制台中更新了它,但无济于事。我如何检查我的凭据或者我还能做些什么来开始解决这个问题?
我会在 config/locales/ 下一个名为 aws.yml 的新 .yml 文件中设置密钥的位置,如下所示:
development:
access_key_id: XXXXXXXXXXXXXX
secret_access_key: XXXXXXXXXXXXXXXX
s3_region: eu-central-1
test:
access_key_id: XXXXXXXXXXXXXXXX
secret_access_key: XXXXXXXXXXXXXXXX
s3_region: eu-central-1
production:
access_key_id: XXXXXXXXXXXXXXXX
secret_access_key: XXXXXXXXXXXXXXXX
s3_region: eu-central-1
然后在具有附件的模型中:
has_attached_file :img
您可以将s3_credentials设为
s3_credentials: "#{Rails.root}/config/aws.yml",
因此您模型中的最终结果应如下所示:
has_attached_file :img,
styles: { :model_index => "250x350", :img_show => "325x475"},
storage: :s3,
url: ':s3_domain_url',
bucket: 'yourbucket',
s3_credentials: "#{Rails.root}/config/aws.yml",
path: "resources/:id/:style/:basename.:extension"
然后在您看来:
<%= @model.model_img.url(:img_show) %>
给你!
我去年参加了开发 RoR 应用程序的课程。我开发了一个使用我的账户密钥和 returns 结果搜索 AWS 的工具。现在,每当我搜索亚马逊时,我都会收到 403 错误。
我重新创建了我的密钥,并在 Rails 控制台中更新了它,但无济于事。我如何检查我的凭据或者我还能做些什么来开始解决这个问题?
我会在 config/locales/ 下一个名为 aws.yml 的新 .yml 文件中设置密钥的位置,如下所示:
development:
access_key_id: XXXXXXXXXXXXXX
secret_access_key: XXXXXXXXXXXXXXXX
s3_region: eu-central-1
test:
access_key_id: XXXXXXXXXXXXXXXX
secret_access_key: XXXXXXXXXXXXXXXX
s3_region: eu-central-1
production:
access_key_id: XXXXXXXXXXXXXXXX
secret_access_key: XXXXXXXXXXXXXXXX
s3_region: eu-central-1
然后在具有附件的模型中:
has_attached_file :img
您可以将s3_credentials设为
s3_credentials: "#{Rails.root}/config/aws.yml",
因此您模型中的最终结果应如下所示:
has_attached_file :img,
styles: { :model_index => "250x350", :img_show => "325x475"},
storage: :s3,
url: ':s3_domain_url',
bucket: 'yourbucket',
s3_credentials: "#{Rails.root}/config/aws.yml",
path: "resources/:id/:style/:basename.:extension"
然后在您看来:
<%= @model.model_img.url(:img_show) %>
给你!