Sha256: 51e1cb6389dd64a1eddd763e65f41d28fafa489d5c7785efbfd4d2336f575353

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 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 [Object] object the source file is attached to
    # @param [File] filestream to be added, should respond to :mime_type, :original_name
    # @param [String] destination_name is the fedora path at which the child resource will be found or created beneath the object.

    def self.call(object, file, destination_path)
      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

1 entries across 1 versions & 1 rubygems

Version Path
hydra-derivatives-2.0.0 lib/hydra/derivatives/services/persist_output_file_service.rb