当我try 将文件上传到新法兰克福地区的S3 bucket时,我遇到了一个错误AWS::S3::Errors::InvalidRequest The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256..所有这些都可以在US Standard区域正常工作.

脚本:

backup_file = '/media/db-backup_for_dev/2014-10-23_02-00-07/slave_dump.sql.gz'
s3 = AWS::S3.new(
    access_key_id:     AMAZONS3['access_key_id'],
    secret_access_key: AMAZONS3['secret_access_key']
)

s3_bucket = s3.buckets['test-frankfurt']

# Folder and file name
s3_name = "database-backups-last20days/#{File.basename(File.dirname(backup_file))}_#{File.basename(backup_file)}"

file_obj = s3_bucket.objects[s3_name]
file_obj.write(file: backup_file)

aws sdk(1.56.0)

如何修复它?

非常感谢.

推荐答案

AWS4-HMAC-SHA256,也称为签名版本4("V4"),是S3支持的两种身份验证方案之一.

All regions support V4, but US-Standard¹, and many -- but not all -- other regions, also support the other, older scheme, Signature Version 2 ("V2").

根据http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html...2014年1月后部署的新S3区域将仅支持V4.

自2014年底引入法兰克福以来,它不支持V2,这一错误表明您正在使用V2.

http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html解释了如何在各种SDK中启用V4,假设您使用的是具有该功能的SDK.

我推测,一些较旧版本的SDK可能不支持此选项,因此,如果上述操作没有帮助,您可能需要使用更新版本的SDK.


¹US Standard is the former name for the S3 regional deployment that is based in the us-east-1 region. Since the time this answer was originally written, "Amazon S3 renamed the US Standard Region to the US East (N. Virginia) Region to be consistent with AWS regional naming conventions." For all practical purposes, it's only a change in naming.

Ruby相关问答推荐

当一个方法在没有参数的 return 关键字上提前退出时,返回什么值?

有没有办法向用户返回 nil 消息但不中断 ruby​​ 中的应用程序?

在Ruby中按字母顺序对数组中的数组进行排序?

Rack并发 - rack.multithread、async.callback 或两者兼而有之?

python:pythonbrew 和 virtualenv 有什么区别?

什么是 Sinatra/Rack 的非常简单的身份验证方案

Ruby 在与源相同的目录中加载配置(yaml)文件

在 Ruby 中,获取第一个块返回 true 的可枚举元素的最快方法是什么?

Ruby:从字节创建一个字符串

为什么 Ruby 使用 respond_to?而不是 responds_to?

Rails - RSpec - let和let!之间的区别

判断 Ruby HTTP 响应是否成功

Ruby 中方法名称的限制是什么?

array.include?多个值

`respond_to?` 与 `respond_to_missing?`

Ruby数组限制方法

Ruby 数组中的奇数(或偶数)条目

我们什么时候在 Rails 中使用 "||=" 运算符?它的意义是什么?

将整个文本文件作为单个字符串读取的合理方法是什么?

Ruby:如何在不指向同一个对象的情况下复制变量?