Module: Ddr::Models::FileManagement
Defined Under Namespace
Classes: FileToAdd
Instance Method Summary collapse
-
#add_file(file, opts = {}) ⇒ Object
Adds ActiveFedora::File Overrides ActiveFedora::AttachedFiles#add_file(file, opts).
Instance Method Details
#add_file(file, opts = {}) ⇒ Object
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.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# 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 |