require 'fog' module Hillary class Slug class Bucket attr_reader :name def initialize(name = ENV['SLUG_BUCKET'], access_key = ENV['AWS_S3_KEY_ID'], secret_key = ENV['AWS_S3_KEY_SECRET']) @name = name @storage = Fog::Storage.new( provider: 'AWS', aws_access_key_id: access_key, aws_secret_access_key: secret_key ) @directory = @storage.directories.get(name) end def write(name, file) @directory.files.create( key: name, body: File.open(file), public: false ) end def copy(source, target) source_file = @directory.files.get(source) source_file.copy(@name, target) end end end end