Class: S3diff::S3Client
- Inherits:
-
Object
- Object
- S3diff::S3Client
- Defined in:
- lib/s3diff/s3_client.rb
Instance Method Summary collapse
- #get_object(s3_uri, file_io, options = {}) ⇒ Object
- #head_object(s3_uri, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ S3Client
constructor
A new instance of S3Client.
- #parse_s3_uri(s3_uri) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ S3Client
Returns a new instance of S3Client.
6 7 8 |
# File 'lib/s3diff/s3_client.rb', line 6 def initialize( = {}) @client = Aws::S3::Client.new() end |
Instance Method Details
#get_object(s3_uri, file_io, options = {}) ⇒ Object
14 15 16 17 18 |
# File 'lib/s3diff/s3_client.rb', line 14 def get_object(s3_uri, file_io, = {}) @client.get_object(.merge(parse_s3_uri(s3_uri))) do |chunk| file_io.write(chunk) end end |
#head_object(s3_uri, options = {}) ⇒ Object
10 11 12 |
# File 'lib/s3diff/s3_client.rb', line 10 def head_object(s3_uri, = {}) @client.head_object(.merge(parse_s3_uri(s3_uri))) end |
#parse_s3_uri(s3_uri) ⇒ Object
20 21 22 23 |
# File 'lib/s3diff/s3_client.rb', line 20 def parse_s3_uri(s3_uri) uri = URI.parse(s3_uri) { bucket: uri.host, key: uri.path.sub(%r{^/}, "") } end |