Putting files to S3 & getting files from S3 should be one liner. In reality, you might be confused with tricky behavior of official aws-sdk
gem. With easys3
, Easys3.put(bucket_name, file_name, file, acl)
means putting files to s3 and Easys3.get(bucket_name, file_name)
means getting a file from s3.
Add this line to your application's Gemfile:
gem 'easys3'
And then execute:
$ bundle
Or install it yourself as:
$ gem install easys3
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_S3_REGION=...
ap-east-1
ap-northeast-1
ap-northeast-2
ap-south-1
ap-southeast-1
ap-southeast-2
ca-central-1
eu-central-1
eu-north-1
eu-west-1
eu-west-2
eu-west-3
sa-east-1
us-east-1
us-east-2
us-west-1
us-west-2
cn-north-1
cn-northwest-1
us-gov-east-1
us-gov-west-1
Easys3.put(bucket_name, file_name, file, acl) # acl is optional
Easys3.put("test-bucket", "test/abc.log", "abc")
{:status=>201, :data=>#<struct Aws::S3::Types::PutObjectOutput ... }
{:status=>500, :message=>#<Aws::Errors::NoSuchEndpointError: ... }
Easys3.get(bucket_name, file_name)
Easys3.get("test-bucket", "test/abc.log")
{:status=>200, :data=>"abc"}
{:status=>404, :message=>"Could not find file: test/missing.log in the bucket: test-bucket"}
{:status=>500, :message=>#<Aws::Errors::NoSuchEndpointError: ... }
Bug reports and pull requests are welcome on GitHub at https://github.com/chienomi/easys3. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Easys3 project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.