Class: Hyrax::Listeners::FileListener

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/listeners/file_listener.rb

Overview

Listens for events related to Files (Valkyrie::StorageAdapter::File)

Instance Method Summary collapse

Instance Method Details

#on_file_characterized(event) ⇒ void

This method returns an undefined value.

Called when ‘file.characterized’ event is published; allows post-characterization handling, like derivatives generation.

Parameters:

  • event (Dry::Events::Event)


14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/services/hyrax/listeners/file_listener.rb', line 14

def on_file_characterized(event)
  file_set = event[:file_set]

  case file_set
  when ActiveFedora::Base # ActiveFedora
    CreateDerivativesJob
      .perform_later(file_set, event[:file_id], event[:path_hint])
  else
    ValkyrieCreateDerivativesJob
      .perform_later(file_set.id.to_s, event[:file_id])
  end
end

#on_file_uploaded(event) ⇒ void

This method returns an undefined value.

Called when ‘file.uploaded’ event is published

Parameters:

  • event (Dry::Events::Event)


31
32
33
34
35
36
# File 'app/services/hyrax/listeners/file_listener.rb', line 31

def on_file_uploaded(event)
  # Run characterization for original file only
  return unless event[:metadata]&.original_file?

  ValkyrieCharacterizationJob.perform_later(event[:metadata].id.to_s)
end