Sha256: 69e4866738d89205d9ce1dcaf63f22cc02d8422c09bbe633c97c5a1b27dfc6b2

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

module Hydra::Derivatives
  class PersistOutputFileService
    # 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)
    # @param [String] file_path the path to the file to be added
    # @param [Hash] directives directions which can be used to determine where to persist to.
    # @option directives [String] url This can determine the path of the object.
    def self.call(_file_path, _directives)
      raise NotImplementedError, "PersistOutputFileService is an abstract class. Implement `call' on #{self.class.name}"
    end

    # @param file [Hydra::Derivatives::IoDecorator]
    def self.determine_original_name(file)
      if file.respond_to? :original_filename
        file.original_filename
      else
        "derivative"
      end
    end

    # @param file [Hydra::Derivatives::IoDecorator]
    def self.determine_mime_type(file)
      if file.respond_to? :mime_type
        file.mime_type
      else
        "appliction/octet-stream"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hydra-derivatives-3.4.2 lib/hydra/derivatives/services/persist_output_file_service.rb
hydra-derivatives-3.4.1 lib/hydra/derivatives/services/persist_output_file_service.rb
hydra-derivatives-3.4.0 lib/hydra/derivatives/services/persist_output_file_service.rb