module Ddr::Models::FileManagement
Constants
- FileToAdd
Public Instance Methods
add_file(file, opts={})
click to toggle source
Adds ActiveFedora::File Overrides ActiveFedora::AttachedFiles#add_file(file, opts)
Options:
:path - The path of the child resource to create :mime_type - Explicit mime type to set (otherwise discerned from file path or name) :original_name - A String value will be understood as the original name of the file. Default processing will take the file basename as the original name.
Calls superclass method
# File lib/ddr/models/file_management.rb, line 26 def add_file file, opts={} opts[:mime_type] ||= Ddr::Utils.mime_type_for(file) opts[:original_name] ||= Ddr::Utils.file_name_for(file) # @file_to_add is set for callbacks to access the data self.file_to_add = file run_callbacks(:add_file) do super end # clear the instance data self.file_to_add = nil end
Protected Instance Methods
notify_virus_scan_results()
click to toggle source
# File lib/ddr/models/file_management.rb, line 56 def notify_virus_scan_results while result = virus_scan_results.shift result.merge! pid: id ActiveSupport::Notifications.instrument(Ddr::Notifications::VIRUS_CHECK, result) end end
virus_scan()
click to toggle source
# File lib/ddr/models/file_management.rb, line 49 def virus_scan path = Ddr::Utils.file_path(file_to_add) virus_scan_results << Ddr::Actions::VirusCheck.call(path) rescue ArgumentError => e # file is a blob logger.error(e) end
virus_scan_results()
click to toggle source
# File lib/ddr/models/file_management.rb, line 45 def virus_scan_results @virus_scan_results ||= [] end