Class: DataMigrater::S3

Inherits:
Object
  • Object
show all
Defined in:
lib/data_migrater/s3.rb

Instance Method Summary collapse

Constructor Details

#initialize(bucket, credentials, csv_path) ⇒ S3

Returns a new instance of S3.



7
8
9
10
11
12
13
# File 'lib/data_migrater/s3.rb', line 7

def initialize(bucket, credentials, csv_path)
  @bucket      = bucket
  @credentials = default_credentials.merge(credentials)
  @csv_path    = csv_path

  ::Aws.config.update @credentials
end

Instance Method Details

#deleteObject



15
16
17
# File 'lib/data_migrater/s3.rb', line 15

def delete
  client.delete_object options
end

#downloadObject



19
20
21
22
23
24
25
# File 'lib/data_migrater/s3.rb', line 19

def download
  client.head_object options

  client.get_object options.merge(response_target: @csv_path)
rescue Aws::S3::Errors::NotFound
  []
end