Class: AWS::S3::S3Object

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

Overview

Methods extending the S3Object class provided by the aws-s3 gem.

Instance Method Summary collapse

Instance Method Details

#save_to(path) ⇒ Object

Copies the S3 Object to a local directory.

save_to('tmp/file.csv')
Copied files are in ISO-8859-1 encoding


16
17
18
19
20
21
22
# File 'lib/extensions/s3.rb', line 16

def save_to(path)
  File.open(path,'wb') do |file|
    S3Object.stream(self.key,self.bucket.name) do |chunk|
      file.write chunk
    end
  end
end

#to_class_nameObject

Returns the class represented by the csv file.

person.csv => Person


9
10
11
# File 'lib/extensions/s3.rb', line 9

def to_class_name
  self.key.gsub('.csv','').capitalize
end