Class: Hyrax::PersistDirectlyContainedOutputFileService

Inherits:
Hydra::Derivatives::PersistBasicContainedOutputFileService
  • Object
show all
Defined in:
app/services/hyrax/persist_directly_contained_output_file_service.rb

Overview

This Service is an implementation of the Hydra::Derivatives::PersistOutputFileService It supports directly contained files

Class Method Summary collapse

Class Method Details

.call(content, directives) ⇒ Object

This method conforms to the signature of the .call method on Hydra::Derivatives::PersistOutputFileService

  • Persists the file within the DirectContainer specified by :container

Parameters:

  • content (String)

    the data to be persisted

  • directives (Hash)

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

Options Hash (directives):

  • url (String)

    URI for the parent object.

  • container (String)

    Name of the container association.



13
14
15
16
17
18
19
20
21
# File 'app/services/hyrax/persist_directly_contained_output_file_service.rb', line 13

def self.call(content, directives)
  file = io(content, directives)
  file_set = retrieve_file_set(directives)
  remote_file = retrieve_remote_file(file_set, directives)
  remote_file.content = file
  remote_file.mime_type = determine_mime_type(file)
  remote_file.original_name = determine_original_name(file)
  file_set.save
end