Module: CurationConcerns::FileSet::Derivatives

Extended by:
ActiveSupport::Concern
Included in:
CurationConcerns::FileSetBehavior
Defined in:
app/models/concerns/curation_concerns/file_set/derivatives.rb

Instance Method Summary collapse

Instance Method Details

#create_derivatives(filename) ⇒ Object

This completely overrides the version in Hydra::Works so that we read and write to a local file. It’s important that characterization runs before derivatives so that we have a credible mime_type field to work with.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/models/concerns/curation_concerns/file_set/derivatives.rb', line 16

def create_derivatives(filename)
  case mime_type
  when *self.class.pdf_mime_types
    Hydra::Derivatives::PdfDerivatives.create(filename,
                                              outputs: [{ label: :thumbnail, format: 'jpg', size: '338x493', url: derivative_url('thumbnail') }])
    Hydra::Derivatives::FullTextExtract.create(filename,
                                               outputs: [{ url: uri, container: "extracted_text" }])
  when *self.class.office_document_mime_types
    Hydra::Derivatives::DocumentDerivatives.create(filename,
                                                   outputs: [{ label: :thumbnail, format: 'jpg',
                                                               size: '200x150>',
                                                               url: derivative_url('thumbnail') }])
    Hydra::Derivatives::FullTextExtract.create(filename,
                                               outputs: [{ url: uri, container: "extracted_text" }])
  when *self.class.audio_mime_types
    Hydra::Derivatives::AudioDerivatives.create(filename,
                                                outputs: [{ label: 'mp3', format: 'mp3', url: derivative_url('mp3') },
                                                          { label: 'ogg', format: 'ogg', url: derivative_url('ogg') }])
  when *self.class.video_mime_types
    Hydra::Derivatives::VideoDerivatives.create(filename,
                                                outputs: [{ label: :thumbnail, format: 'jpg', url: derivative_url('thumbnail') },
                                                          { label: 'webm', format: 'webm', url: derivative_url('webm') },
                                                          { label: 'mp4', format: 'mp4', url: derivative_url('mp4') }])
  when *self.class.image_mime_types
    Hydra::Derivatives::ImageDerivatives.create(filename,
                                                outputs: [{ label: :thumbnail, format: 'jpg', size: '200x150>', url: derivative_url('thumbnail') }])
  end
end