From 9be479025dab9f924db24f06e1e412cf1e3a84d7 Mon Sep 17 00:00:00 2001 From: Peter Mangiafico Date: Thu, 10 Aug 2017 10:13:37 -0700 Subject: [PATCH] tell carrierwave to use move instead of copy during uploads --- app/uploaders/file_uploader.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index ac318b1f3..b235605ae 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -18,6 +18,19 @@ class FileUploader < CarrierWave::Uploader::Base before :store, :remember_cache_id after :store, :delete_tmp_dir + ## + # By default, CarrierWave copies an uploaded file twice, first copying the file into the cache, then copying the file into the store. + # For large files, this can be prohibitively time consuming. + # You may change this behavior by overriding either or both of the move_to_cache and move_to_store methods and set values to true. + def move_to_cache + true + end + + def move_to_store + true + end + ## + # store! nil's the cache_id after it finishes so we need to remember it for deletion def remember_cache_id(new_file) @cache_id_was = cache_id