Class: Hyrax::DownloadsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Hydra::Controller::DownloadBehavior, LocalFileDownloadsControllerBehavior, StreamFileDownloadsControllerBehavior, ValkyrieDownloadsControllerBehavior, WorkflowsHelper
Defined in:
app/controllers/hyrax/downloads_controller.rb

Direct Known Subclasses

SingleUseLinksViewerController

Class Method Summary collapse

Instance Method Summary collapse

Methods included from WorkflowsHelper

#workflow_restriction?

Methods included from ValkyrieDownloadsControllerBehavior

#show_valkyrie

Class Method Details

.default_content_pathObject



10
11
12
# File 'app/controllers/hyrax/downloads_controller.rb', line 10

def self.default_content_path
  :original_file
end

Instance Method Details

#hydra_show_active_fedora_fileObject

We want to alias the show method for a later use with #show_active_fedora; because we’re adding quite a bit of logic and need a good alias. Why the alias? Because we were using ‘super’ for the show method and that just doesn’t quite work with all of the antics we’re performing.



18
# File 'app/controllers/hyrax/downloads_controller.rb', line 18

alias hydra_show_active_fedora_file show

#showObject

Render the 404 page if the file doesn’t exist. Otherwise renders the file.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/hyrax/downloads_controller.rb', line 22

def show
  # We will use the thumbnail from our file system first, if one exists
  # Otherwise we will fallback to Valkyrie, then the default implementations
  use = params.fetch(:file, :original_file).to_sym
  if use == :thumbnail
    thumbnail = Hyrax::DerivativePath.derivative_path_for_reference(params[:id], 'thumbnail')
    if thumbnail.present? && File.exist?(thumbnail)
      @file = thumbnail
      return send_local_content
    end
  end

  return show_valkyrie if Hyrax.config.use_valkyrie?

  show_active_fedora
end