Class: S3diff::S3Client

Inherits:
Object
  • Object
show all
Defined in:
lib/s3diff/s3_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ S3Client

Returns a new instance of S3Client.



6
7
8
# File 'lib/s3diff/s3_client.rb', line 6

def initialize(options = {})
  @client = Aws::S3::Client.new(options)
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, options = {})
  @client.get_object(options.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, options = {})
  @client.head_object(options.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