Amazon S3 + Fog warning: connecting to the matching region will be more performant

喜夏-厌秋 提交于 2019-12-01 15:05:18

问题


I get the following warning while querying Amazon S3 via the Fog gem:

[WARNING] fog: followed redirect to my-bucket.s3-external-3.amazonaws.com, connecting to the matching region will be more performant

How exactly do I "connect to the matching region"?


回答1:


Set the :region option in the Fog connection parameters to the name of the region in which your bucket exists.

For example, I have a bucket called "bucket-a" in region "eu-west-1" and my s3 key and secret are in variables s3_key and s3_secret respectively.

I can connect to this region directly by opening my Fog connection as follows:

s3 = Fog::Storage.new(provider: 'AWS', aws_access_key_id: s3_key, aws_secret_access_key: s3_secret, region: 'eu-west-1')

And now when I list the contents, no region warning is issued:

s3.directories.get('bucket-a').files

If you want to do this for all your buckets, rather than on a bucket-by-bucket basis you can set the following:

Fog::Storage::AWS::DEFAULT_REGION = 'eu-west-1'


来源:https://stackoverflow.com/questions/16659691/amazon-s3-fog-warning-connecting-to-the-matching-region-will-be-more-performa

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!