Class: Ploy::S3Storage

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

Instance Method Summary collapse

Constructor Details

#initialize(bucket) ⇒ S3Storage



5
6
7
# File 'lib/ploy/s3storage.rb', line 5

def initialize(bucket)
  @bucketname = bucket
end

Instance Method Details

#copy(from, to) ⇒ Object



16
17
18
# File 'lib/ploy/s3storage.rb', line 16

def copy(from, to)
  AWS::S3.new.buckets[@bucketname].objects[from].copy_to(to)
end

#get(from, fileio) ⇒ Object



20
21
22
23
24
25
# File 'lib/ploy/s3storage.rb', line 20

def get(from, fileio)
  AWS::S3.new.buckets[@bucketname].objects[from].read do |chunk|
    fileio.write(chunk)
  end
  fileio.flush
end

#metadata(loc) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/ploy/s3storage.rb', line 27

def (loc)
  o = AWS::S3.new.buckets[@bucketname].objects[loc] 
  if (o.exists?) then
    return o.
  else
    return {}
  end
end

#put(path, name, meta = {}) ⇒ Object



9
10
11
12
13
14
# File 'lib/ploy/s3storage.rb', line 9

def put(path, name, meta = {})
  AWS::S3.new.buckets[@bucketname].objects[name].write(
    Pathname.new(path),
    { :metadata => meta },
  )
end