How can I make carrierwave not save the original file after versions are processed?

前端 未结 5 1167
广开言路
广开言路 2020-12-16 04:17

I\'m using CarrierWave for my file uploads in Rails 3.1, and I\'m looking for a way to save server space. Many of the photos being uploaded are upwards of 20MB, so after pro

5条回答
  •  清酒与你
    2020-12-16 04:49

    class FileUploader < CarrierWave::Uploader::Base
    
      after :store, :delete_original_file
    
      def delete_original_file(new_file)
        File.delete path if version_name.blank?
      end
    
      include CarrierWave::RMagick
    
      storage :file
      .
      . # other configurations
    
    end
    

提交回复
热议问题