Class: Hydra::Derivatives::PersistExternalFileOutputFileService

Inherits:
PersistOutputFileService show all
Defined in:
lib/hydra/derivatives/services/persist_external_file_output_file_service.rb

Class Method Summary collapse

Methods inherited from PersistOutputFileService

determine_mime_type, determine_original_name

Class Method Details

.call(output, directives) ⇒ Object

Persists a new file at specified location that points to external content

Parameters:

  • output (Hash)

    information about the external derivative file

  • directives (Hash)

    directions which can be used to determine where to persist to.

Options Hash (output):

  • url (String)

    the location of the external content

Options Hash (directives):

  • url (String)

    This can determine the path of the object.



11
12
13
14
15
16
17
18
19
# File 'lib/hydra/derivatives/services/persist_external_file_output_file_service.rb', line 11

def self.call(output, directives)
  external_file = ActiveFedora::File.new(directives[:url])
  # TODO: Replace the following two lines with the shorter call to #external_url once active_fedora/pull/1234 is merged
  external_file.content = ''
  external_file.mime_type = "message/external-body; access-type=URL; URL=\"#{output[:url]}\""
  # external_file.external_url = output[:url]
  external_file.original_name = Addressable::URI.parse(output[:url]).path.split('/').last
  external_file.save
end