diff --git a/lib/fog/local/models/storage/file.rb b/lib/fog/local/models/storage/file.rb index 36c9701a7..efff3e02c 100644 --- a/lib/fog/local/models/storage/file.rb +++ b/lib/fog/local/models/storage/file.rb @@ -65,7 +65,7 @@ module Fog end def path - connection.path_to(::File.join(directory.key, key)) + connection.path_to(::File.join(directory.key, CGI.escape(key))) end end diff --git a/lib/fog/local/models/storage/files.rb b/lib/fog/local/models/storage/files.rb index 944225a5f..53ab05d93 100644 --- a/lib/fog/local/models/storage/files.rb +++ b/lib/fog/local/models/storage/files.rb @@ -20,7 +20,7 @@ module Fog path = file_path(key) { :content_length => ::File.size(path), - :key => key, + :key => CGI.unescape(key), :last_modified => ::File.mtime(path) } end @@ -32,7 +32,7 @@ module Fog def get(key, &block) requires :directory - path = file_path(key) + path = file_path(CGI.escape(key)) if ::File.exists?(path) data = { :content_length => ::File.size(path), @@ -53,6 +53,20 @@ module Fog end end + def head(key) + requires :directory + path = file_path(CGI.escape(key)) + if ::File.exists?(path) + new({ + :content_length => ::File.size(path), + :key => key, + :last_modified => ::File.mtime(path) + }) + else + nil + end + end + def new(attributes = {}) requires :directory super({ :directory => directory }.merge!(attributes))