Sha256: 2e33a50b8b1499d643df395d4bf1cb09f429d77f3d9a37e9c04c126edf0121b5
Contents?: true
Size: 1.38 KB
Versions: 41
Compression:
Stored size: 1.38 KB
Contents
module CurationConcerns # This Service is an implementation of the Hydra::Derivatives::PersistOutputFileService # It supports directly contained files class PersistDirectlyContainedOutputFileService < Hydra::Derivatives::PersistBasicContainedOutputFileService # This method conforms to the signature of the .call method on Hydra::Derivatives::PersistOutputFileService # * Persists the file within the DirectContainer specified by :container # # @param [#read] stream the data to be persisted # @param [Hash] directives directions which can be used to determine where to persist to. # @option directives [String] url URI for the parent object. # @option directives [String] container Name of the container association. def self.call(stream, directives) file = Hydra::Derivatives::IoDecorator.new(stream, new_mime_type(directives.fetch(:format))) o_name = determine_original_name(file) m_type = determine_mime_type(file) uri = URI(directives.fetch(:url)) raise ArgumentError, "#{uri} is not an http uri" unless uri.scheme == 'http' file_set = ActiveFedora::Base.find(ActiveFedora::Base.uri_to_id(uri.to_s)) remote_file = file_set.send("build_#{directives.fetch(:container)}".to_sym) remote_file.content = file remote_file.mime_type = m_type remote_file.original_name = o_name file_set.save end end end
Version data entries
41 entries across 41 versions & 2 rubygems