Sha256: c3e552eb7638e7294e80a36334443e268cc6ee5aec1b5c16e9b9d5c36e2c40c2

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 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

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

    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

7 entries across 7 versions & 1 rubygems

Version Path
hydra-derivatives-3.3.2 lib/hydra/derivatives/services/persist_output_file_service.rb
hydra-derivatives-3.3.1 lib/hydra/derivatives/services/persist_output_file_service.rb
hydra-derivatives-3.3.0 lib/hydra/derivatives/services/persist_output_file_service.rb
hydra-derivatives-3.2.2 lib/hydra/derivatives/services/persist_output_file_service.rb
hydra-derivatives-3.2.1 lib/hydra/derivatives/services/persist_output_file_service.rb
hydra-derivatives-3.2.0 lib/hydra/derivatives/services/persist_output_file_service.rb
hydra-derivatives-3.1.4 lib/hydra/derivatives/services/persist_output_file_service.rb