Class: BackupPants::S3

Inherits:
Object
  • Object
show all
Defined in:
lib/backup-pants/s3.rb

Instance Method Summary collapse

Constructor Details

#initialize(key, secret) ⇒ S3

Returns a new instance of S3.



3
4
5
6
7
8
# File 'lib/backup-pants/s3.rb', line 3

def initialize(key, secret)
  @key = key
  @secret = secret
  @prepped_buckets = {}
  establish_connection
end

Instance Method Details

#upload(bucket, file, dir_prefix = '') ⇒ Object

dir_prefix should end with slash: ‘hello/hi/’



11
12
13
14
15
# File 'lib/backup-pants/s3.rb', line 11

def upload(bucket, file, dir_prefix='')
  prep_bucket(bucket)
  filename = file.split(/\//).last
  AWS::S3::S3Object.store(dir_prefix + filename, open(file), bucket)
end