Sha256: 346cc353dde98a7038b5553089302716d3072fefb828ab1b38d0cb00aa7aca68

Contents?: true

Size: 873 Bytes

Versions: 7

Compression:

Stored size: 873 Bytes

Contents

# frozen_string_literal: true
class ValkyrieCreateDerivativesJob < Hyrax::ApplicationJob
  queue_as Hyrax.config.ingest_queue_name
  def perform(_file_set_id, file_id, _filepath = nil)
    file_metadata = Hyrax.custom_queries.find_file_metadata_by(id: file_id)
    return if file_metadata.video? && !Hyrax.config.enable_ffmpeg
    # Get file into a local path.
    file = Hyrax.storage_adapter.find_by(id: file_metadata.file_identifier)
    # Call derivatives with the file_set.
    derivative_service = Hyrax::DerivativeService.for(file_metadata)
    derivative_service.create_derivatives(file.disk_path)
    # Trigger a reindex to get the thumbnail path.
    Hyrax.publisher.publish('file.metadata.updated', metadata: file_metadata, user: nil)
  end

  private

  def query_service
    Hyrax.query_service
  end

  def storage_adapter
    Hyrax.storage_adapter
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hyrax-3.6.0 app/jobs/valkyrie_create_derivatives_job.rb
hyrax-3.5.0 app/jobs/valkyrie_create_derivatives_job.rb
hyrax-4.0.0.beta2 app/jobs/valkyrie_create_derivatives_job.rb
hyrax-3.4.2 app/jobs/valkyrie_create_derivatives_job.rb
hyrax-4.0.0.beta1 app/jobs/valkyrie_create_derivatives_job.rb
hyrax-3.4.1 app/jobs/valkyrie_create_derivatives_job.rb
hyrax-3.4.0 app/jobs/valkyrie_create_derivatives_job.rb