Class: Hyrax::SingleUseLinksViewerController

Inherits:
DownloadsController show all
Includes:
ActionDispatch::Routing::PolymorphicRoutes, Blacklight::AccessControls::Catalog, Blacklight::Base
Defined in:
app/controllers/hyrax/single_use_links_viewer_controller.rb

Defined Under Namespace

Classes: Ability

Instance Method Summary collapse

Methods inherited from DownloadsController

default_content_path

Instance Method Details

#downloadObject


15
16
17
18
# File 'app/controllers/hyrax/single_use_links_viewer_controller.rb', line 15

def download
  raise not_found_exception unless single_use_link.path == hyrax.download_path(id: @asset)
  send_content
end

#showObject


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/hyrax/single_use_links_viewer_controller.rb', line 20

def show
  _, document_list = search_results(id: single_use_link.itemId)
  curation_concern = document_list.first

  # Authorize using SingleUseLinksViewerController::Ability
  authorize! :read, curation_concern
  raise not_found_exception unless single_use_link.path == polymorphic_path([main_app, curation_concern])

  # show the file
  @presenter = presenter_class.new(curation_concern, current_ability)

  # create a dowload link that is single use for the user since we do not just want to show metadata we want to access it too
  @su = single_use_link.create_for_path hyrax.download_path(curation_concern.id)
  @download_link = hyrax.download_single_use_link_path(@su.downloadKey)
end