简体   繁体   中英

Upload files to AWS S3 with plain Ruby

I'm trying to list the files in the bucket named 0-test on S3 using the aws-sdk gem. This is my code:

require require 'aws-sdk'

Aws.config.update({
  region: 'Ireland',
  credentials: Aws::Credentials.new(key, key2)
})

s3 = Aws::S3::Client.new
print s3.list_buckets

This is the (important part of the) error I get:

/Users/user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/net/http.rb:879:in `initialize': unable to connect to `s3.ireland.amazonaws.com`; SocketError: getaddrinfo: nodename nor servname provided, or not known (Seahorse::Client::NetworkingError)

What am I missing? Thanks!

Your region name is incorrect. While that region is colloquially known as Ireland, the API name is eu-west-1 . There is a full list of regions here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM