Skip to content
This repository has been archived by the owner on Jan 8, 2022. It is now read-only.

Commit

Permalink
tell carrierwave not to use move instead of copy during uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
peetucket committed Aug 10, 2017
1 parent 1ca3ffa commit 413095d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/uploaders/file_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 413095d

Please sign in to comment.