Sha256: e400cd20c26c8006f8c083b9548ed0a56b29408838af569883bcd6c1de8d7922
Contents?: true
Size: 860 Bytes
Versions: 29
Compression:
Stored size: 860 Bytes
Contents
module Sufia module GenericFile module VirusCheck extend ActiveSupport::Concern included do validate :detect_viruses end # Default behavior is to raise a validation error and halt the save if a virus is found def detect_viruses return unless content.changed? path = if content.content.respond_to?(:path) content.content.path else Tempfile.open('') do |t| t.binmode t.write(content.content) t.close t.path end end Sufia::GenericFile::Actor.virus_check(path) true rescue Sufia::VirusFoundError => virus logger.warn(virus.message) errors.add(:base, virus.message) false end end end end
Version data entries
29 entries across 29 versions & 2 rubygems