【发布时间】:2013-05-20 23:04:01
【问题描述】:
我在通过 Fog gem 查询 Amazon S3 时收到以下警告:
[WARNING] fog: followed redirect to my-bucket.s3-external-3.amazonaws.com, connecting to the matching region will be more performant
我究竟如何“连接到匹配区域”?
【问题讨论】:
我在通过 Fog gem 查询 Amazon S3 时收到以下警告:
[WARNING] fog: followed redirect to my-bucket.s3-external-3.amazonaws.com, connecting to the matching region will be more performant
我究竟如何“连接到匹配区域”?
【问题讨论】:
将 Fog 连接参数中的 :region 选项设置为您的存储桶所在区域的名称。
例如,我在区域“eu-west-1”中有一个名为“bucket-a”的存储桶,我的 s3 密钥和秘密分别位于变量 s3_key 和 s3_secret 中。
我可以通过打开我的 Fog 连接直接连接到该区域,如下所示:
s3 = Fog::Storage.new(provider: 'AWS', aws_access_key_id: s3_key, aws_secret_access_key: s3_secret, region: 'eu-west-1')
现在当我列出内容时,不会发出区域警告:
s3.directories.get('bucket-a').files
如果您想对所有存储桶执行此操作,而不是逐个存储桶,您可以设置以下内容:
Fog::Storage::AWS::DEFAULT_REGION = 'eu-west-1'
【讨论】:
region: 'ap-southeast-1' 参数,我仍然收到@clozach 提到的警告
fog_region,最终以region 的形式传递给雾。 {aws_access_key_id: <aws_key>, aws_secret_access_key: <aws_secret>, fog_provider: 'AWS', fog_directory: <bucket_name>, fog_region: 'ap-southeast-1'}
Fog::Storage::AWS.send(:remove_const, 'DEFAULT_REGION') Fog::Storage::AWS::DEFAULT_REGION = 'eu-west-1' 来避免警告。