gpt4 book ai didi

ruby-on-rails - AWS 和 Rails : The authorization header is malformed; the Credential is mal-formed

转载 作者:太空宇宙 更新时间:2023-11-03 17:44:37 25 4
gpt4 key购买 nike

我正在尝试从生产服务器访问我的 S3 存储桶。在开发中一切正常,但是在我的产品控制台中我得到:

Aws::S3::Errors::AuthorizationHeaderMalformed: The authorization header is malformed; the Credential is mal-formed; expecting "<YOUR-AKID>/YYYYMMDD/REGION/SERVICE/aws4_request".

我的代码:

class AwsFileDownloader
def initialize(args)
@s3 = Aws::S3::Client.new
@aws_file_path = ...
end

def get_file
temp_file = File.new('temp.csv', 'r+')
@s3.get_object({bucket: Rails.application.secrets.aws_bucket, key: @aws_file_path}, target: temp_file)
...
end
end

我的 aws 初始化程序(似乎在两种环境中都可以正常工作):

require 'aws-sdk'

Aws.config.update({
region: Rails.application.secrets.aws_region,
credentials: Aws::Credentials.new(Rails.application.secrets.access_key_id, Rails.application.secrets.secret_access_key)
})

感谢任何建议!

最佳答案

这个答案很晚,但也许有人会发现它有用。以上错误是当您切换 AWS KEY IDAWS ACCESS KEY 时导致的。

在正确的地方使用正确的凭据,它应该可以解决您的问题。

关于ruby-on-rails - AWS 和 Rails : The authorization header is malformed; the Credential is mal-formed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42648955/

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