Class: Rstreet::S3

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

Instance Method Summary collapse

Constructor Details

#initialize(s3_bucket) ⇒ S3

Returns a new instance of S3.



5
6
7
8
# File 'lib/s3.rb', line 5

def initialize(s3_bucket)
  @s3 = AWS::S3.new
  @s3_bucket = s3_bucket
end

Instance Method Details

#get_file(uploadable) ⇒ Object



10
11
12
13
# File 'lib/s3.rb', line 10

def get_file(uploadable)
  @s3.buckets[@s3_bucket].objects[uploadable.name].read
rescue AWS::S3::Errors::NoSuchKey
end

#put_file(uploadable) ⇒ Object



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

def put_file(uploadable)
  @s3.buckets[@s3_bucket].objects[uploadable.name].write(file: uploadable.path, acl: :authenticated_read)
end