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

Commit

Permalink
Merge pull request #149 from sul-dlss/use-move-instead-of-copy-for-up…
Browse files Browse the repository at this point in the history
…loads

tell carrierwave to use move instead of copy during uploads
  • Loading branch information
justinlittman authored Jan 14, 2020
2 parents 73d8556 + 9be4790 commit e2eb598
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 e2eb598

Please sign in to comment.