Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS SDK v2 for s3

Can any one provide me a good documentation for uploading files to S3 using asw-sdk Version 2. I checked out the main doc and in v1 we used to do like

s3 = AWS::S3.new
obj = s3.buckets['my-bucket']

Now in v2 when I try as

s3 = Aws::S3::Client.new

am ending up with

Aws::Errors::MissingRegionError: missing region; use :region option or export region name to ENV['AWS_REGION']

Can anyone help me with this?

like image 383
user3655415 Avatar asked Mar 03 '15 05:03

user3655415


People also ask

Do I need to close S3Object?

If you retrieve an S3Object, you should close this input stream as soon as possible, because the object contents aren't buffered in memory and stream directly from Amazon S3. Further, failure to close this stream can cause the request pool to become blocked.

What is AWS SDK Ruby?

The AWS SDK for Ruby helps you to get started building applications using Amazon Web Services infrastructure services, including Amazon S3, Amazon EC2, Amazon DynamoDB, and more.


1 Answers

As per official documentation:

To use the Ruby SDK, you must configure a region and credentials.

Therefore,

s3 = Aws::S3::Client.new(region:'us-west-2')

Alternatively, a default region can be loaded from one of the following locations:

Aws.config[:region]
ENV['AWS_REGION']
like image 58
shivam Avatar answered Sep 18 '22 01:09

shivam