lib/carrierwave/uploader/cache.rb in carrierwave-0.7.1 vs lib/carrierwave/uploader/cache.rb in carrierwave-0.8.0
- old
+ new
@@ -68,21 +68,24 @@
#
# 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!
+ cache!
+ end
+
+ def sanitized_file
_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
+ sanitized
end
##
# Returns a String which uniquely identifies the currently cached file for later retrieval
#
@@ -108,10 +111,10 @@
#
# === Raises
#
# [CarrierWave::FormNotMultipart] if the assigned parameter is a string
#
- def cache!(new_file)
+ def cache!(new_file = sanitized_file)
new_file = CarrierWave::SanitizedFile.new(new_file)
unless new_file.empty?
raise CarrierWave::FormNotMultipart if new_file.is_path? && ensure_multipart_form