lib/saviour/base_uploader.rb in saviour-0.4.5 vs lib/saviour/base_uploader.rb in saviour-0.4.6
- old
+ new
@@ -17,21 +17,34 @@
def respond_to_missing?(name, *)
@data.key?(name) || super
end
- def write(contents, filename)
- raise RuntimeError, "Please use `store_dir` before trying to write" unless store_dir
+ def _process_as_contents(contents, filename)
+ raise ConfigurationError, "Please use `store_dir` in the uploader" unless store_dir
catch(:halt_process) do
if Config.processing_enabled
contents, filename = Uploader::ProcessorsRunner.new(self).run!(contents, filename)
end
path = ::File.join(store_dir, filename)
- Config.storage.write(contents, path)
- path
+ [contents, path]
+ end
+ end
+
+ def _process_as_file(file, filename)
+ raise ConfigurationError, "Please use `store_dir` in the uploader" unless store_dir
+
+ catch(:halt_process) do
+ if Config.processing_enabled
+ file, filename = Uploader::ProcessorsRunner.new(self).run_as_file!(file, filename)
+ end
+
+ path = ::File.join(store_dir, filename)
+
+ [file, path]
end
end
def halt_process
throw(:halt_process)