Class: Hydra::Derivatives::PersistOutputFileService

Inherits:
Object
  • Object
show all
Defined in:
lib/hydra/derivatives/services/persist_output_file_service.rb

Direct Known Subclasses

PersistBasicContainedOutputFileService

Class Method Summary collapse

Class Method Details

.call(object, file, destination_path) ⇒ Object

Persists the file within the object at destination_name. Uses basic containment. If you want to use direct containment (ie. with PCDM) you must use a different service (ie. Hydra::Works::AddFileToGenericFile Service)

Parameters:

  • object (Object)

    the source file is attached to

  • filestream (File)

    to be added, should respond to :mime_type, :original_name

  • destination_name (String)

    is the fedora path at which the child resource will be found or created beneath the object.

Raises:

  • (NotImplementedError)


10
11
12
# File 'lib/hydra/derivatives/services/persist_output_file_service.rb', line 10

def self.call(object, file, destination_path)
  raise NotImplementedError, "PersistOutputFileService is an abstract class. Implement `call' on #{self.class.name}"
end

.determine_mime_type(file) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/hydra/derivatives/services/persist_output_file_service.rb', line 22

def self.determine_mime_type( file )
  if file.respond_to? :mime_type
     file.mime_type
   else
     "appliction/octet-stream"
   end
end

.determine_original_name(file) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/hydra/derivatives/services/persist_output_file_service.rb', line 14

def self.determine_original_name( file )
  if file.respond_to? :original_name
     file.original_name
   else
     "derivative"
   end
end