Class: P2bBackup::Providers::S3

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

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ S3

Returns a new instance of S3.



6
7
8
9
10
11
12
13
# File 'lib/p2b-backup/providers/s3.rb', line 6

def initialize(opts = {})
  @client = Aws::S3::Client.new(
    region: opts[:region],
    access_key_id: opts[:access_key_id],
    secret_access_key: opts[:secret_access_key]
  )
  @bucket = opts[:bucket]
end

Instance Method Details

#upload(file_or_io) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/p2b-backup/providers/s3.rb', line 15

def upload(file_or_io)
  @client.put_object(
    {
      body: file_or_io,
      bucket: @bucket,
      key: 'HappyFace.jpg'
    }
  )
  puts "Uploaded to #{@bucket}"
end