Set the: region option in the Fog connection options to the name of the region in which your bucket exists.
For example, I have a bucket called "bucket-a" in the "eu-west-1" area, and my s3 key and secret are in the s3_key and s3_secret variables respectively.
I can connect to this area 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, a warning about the region is not issued:
s3.directories.get('bucket-a').files
If you want to do this for all of your buckets, and not by default, you can set the following:
Fog::Storage::AWS::DEFAULT_REGION = 'eu-west-1'
Jim riordan
source share