class Vman::S3

Public Class Methods

new(bucket_uri) click to toggle source
# File lib/vman/s3.rb, line 6
def initialize(bucket_uri)
  @bucket ||= Aws::S3::Resource.new.bucket(bucket_uri[5..-1])
end

Public Instance Methods

find(key) click to toggle source
# File lib/vman/s3.rb, line 14
def find(key)
  @bucket.objects({ prefix: key })
end
list() click to toggle source
# File lib/vman/s3.rb, line 10
def list
  @bucket.objects
end
store(file_path, key) click to toggle source
# File lib/vman/s3.rb, line 18
def store(file_path, key)
  @bucket.put_object({
    body: File.open(file_path),
    key: key
  })
end
versions(key) click to toggle source

TODO custom, more descriptive error class

# File lib/vman/s3.rb, line 26
def versions(key)
  _versions = @bucket.object_versions({ prefix: key })

  if _versions.count == 0
    raise "No object exists for supplied key: #{key}"
  end

  _versions
end