Class: Redata::S3Bucket

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

Instance Method Summary collapse

Constructor Details

#initializeS3Bucket

Returns a new instance of S3Bucket.



3
4
5
6
# File 'lib/redata/bucket.rb', line 3

def initialize
  s3 = Aws::S3::Resource.new
  @bucket = s3.bucket RED.s3['bucket']
end

Instance Method Details

#delete(file) ⇒ Object



18
19
20
# File 'lib/redata/bucket.rb', line 18

def delete(file)
  @bucket.object(file).delete if exist?(file)
end

#exist?(file) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/redata/bucket.rb', line 14

def exist?(file)
  @bucket.object(file).exists?
end

#make_public(file, is_public) ⇒ Object



22
23
24
25
# File 'lib/redata/bucket.rb', line 22

def make_public(file, is_public)
  acl = is_public ? 'public-read' : 'private'
  @bucket.object(file).acl.put({:acl => acl}) if exist?(file)
end

#move(source, target) ⇒ Object



8
9
10
11
12
# File 'lib/redata/bucket.rb', line 8

def move(source, target)
  from = @bucket.object source
  to = @bucket.object target
  from.move_to to if from.exists?
end