lib/carrierwave/uploader/cache.rb in carrierwave-0.6.2 vs lib/carrierwave/uploader/cache.rb in carrierwave-0.7.0
- old
+ new
@@ -68,13 +68,20 @@
#
# This is useful when about to process images. Most processing solutions
# require the file to be stored on the local filesystem.
#
def cache_stored_file!
- sanitized = SanitizedFile.new :tempfile => StringIO.new(file.read),
- :filename => File.basename(path), :content_type => file.content_type
+ _content = file.read
+ if _content.is_a?(File) # could be if storage is Fog
+ sanitized = CarrierWave::Storage::Fog.new(self).retrieve!(File.basename(_content.path))
+ sanitized.read if sanitized.exists?
+ else
+ sanitized = SanitizedFile.new :tempfile => StringIO.new(file.read),
+ :filename => File.basename(path), :content_type => file.content_type
+ end
+
cache! sanitized
end
##
# Returns a String which uniquely identifies the currently cached file for later retrieval
@@ -114,12 +121,12 @@
@filename = new_file.filename
self.original_filename = new_file.filename
if move_to_cache
- @file = new_file.move_to(cache_path, permissions)
+ @file = new_file.move_to(cache_path, permissions, directory_permissions)
else
- @file = new_file.copy_to(cache_path, permissions)
+ @file = new_file.copy_to(cache_path, permissions, directory_permissions)
end
end
end
end