lib/saviour/s3_storage.rb in saviour-0.3.1 vs lib/saviour/s3_storage.rb in saviour-0.4.0
- old
+ new
@@ -1,15 +1,17 @@
+require 'fog/aws'
+
module Saviour
class S3Storage
def initialize(conf = {})
@bucket = conf.delete(:bucket)
@public_url_prefix = conf.delete(:public_url_prefix)
@conf = conf
@overwrite_protection = conf.delete(:overwrite_protection) { true }
@create_options = conf.delete(:create_options) { {} }
- conf.fetch(:aws_access_key_id) { raise ArgumentError.new("aws_access_key_id is required")}
- conf.fetch(:aws_secret_access_key) { raise ArgumentError.new("aws_secret_access_key is required")}
+ conf.fetch(:aws_access_key_id) { raise ArgumentError.new("aws_access_key_id is required") }
+ conf.fetch(:aws_secret_access_key) { raise ArgumentError.new("aws_secret_access_key is required") }
end
def write(contents, path)
raise(RuntimeError, "The path you're trying to write already exists!") if @overwrite_protection && exists?(path)
@@ -64,13 +66,13 @@
def assert_exists(path)
raise RuntimeError, "File does not exists: #{path}" unless exists?(path)
end
def directory
- @directory ||= connection.directories.get(@bucket)
+ @directory ||= connection.directories.new(key: @bucket)
end
def connection
- @connection ||= Fog::Storage.new({provider: 'AWS'}.merge(@conf))
+ @connection ||= Fog::Storage.new({ provider: 'AWS' }.merge(@conf))
end
end
end