Sha256: 072c7e16fa5e434d9bc4e07fc2d2552ebd08e407875fa758f09f38e38ee2ae58

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

require 'addressable'

module Hydra::Derivatives
  class PersistExternalFileOutputFileService < PersistOutputFileService
    # Persists a new file at specified location that points to external content
    # @param [Hash] output information about the external derivative file
    # @option output [String] url the location of the external content
    # @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(output, directives)
      external_file = ActiveFedora::File.new(directives[:url])
      # TODO: Replace the following two lines with the shorter call to #external_url once active_fedora/pull/1234 is merged
      external_file.content = ''
      external_file.mime_type = "message/external-body; access-type=URL; URL=\"#{output[:url]}\""
      # external_file.external_url = output[:url]
      external_file.original_name = Addressable::URI.parse(output[:url]).path.split('/').last
      external_file.save
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hydra-derivatives-3.7.0 lib/hydra/derivatives/services/persist_external_file_output_file_service.rb
hydra-derivatives-3.6.1 lib/hydra/derivatives/services/persist_external_file_output_file_service.rb
hydra-derivatives-3.6.0 lib/hydra/derivatives/services/persist_external_file_output_file_service.rb
hydra-derivatives-3.5.0 lib/hydra/derivatives/services/persist_external_file_output_file_service.rb
hydra-derivatives-3.4.2 lib/hydra/derivatives/services/persist_external_file_output_file_service.rb
hydra-derivatives-3.4.1 lib/hydra/derivatives/services/persist_external_file_output_file_service.rb
hydra-derivatives-3.4.0 lib/hydra/derivatives/services/persist_external_file_output_file_service.rb
hydra-derivatives-3.3.2 lib/hydra/derivatives/services/persist_external_file_output_file_service.rb
hydra-derivatives-3.3.1 lib/hydra/derivatives/services/persist_external_file_output_file_service.rb
hydra-derivatives-3.3.0 lib/hydra/derivatives/services/persist_external_file_output_file_service.rb