Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
AWS S3 ruby v2 API usage
require 'aws-sdk'
require 'aws-sdk-resources'
config = {region: 'us-west-1', bucket: 'test', key: 'key', secret: 'secret'}
Aws.config.update({region: config[:region], credentials:[:key], config[:secret])})
bucket = config[:bucket])
# ============
# Create file.
obj = bucket.object(path)
obj.put(body: 'hello')
# Check if file exists.
# Get URL for.
obj.presigned_url(:get, expires_in: 3600)
# Iterate.
bucket.objects.each { |obj| puts "#{obj.key} => #{obj.etag}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.