Class: SingleUseLinkController
- Inherits:
-
DownloadsController
- Object
- ApplicationController
- DownloadsController
- SingleUseLinkController
- Defined in:
- app/controllers/single_use_link_controller.rb
Instance Method Summary collapse
Methods included from Sufia::DownloadsControllerBehavior
Instance Method Details
#download ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/single_use_link_controller.rb', line 29 def download #look up the item link = lookup_hash #grab the item id id = link.itemId #check to make sure the path matches not_found if link.path != sufia.download_path(id) # send the data content @asset = GenericFile.load_instance_from_solr(id) load_datastream send_content(asset) end |
#generate_download ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'app/controllers/single_use_link_controller.rb', line 11 def generate_download @su = SingleUseLink.create_download(params[:id]) @link = sufia.download_single_use_link_path(@su.downloadKey) respond_to do |format| format.html format.js {render :js => @link} end end |
#generate_show ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/controllers/single_use_link_controller.rb', line 20 def generate_show @su = SingleUseLink.create_show(params[:id]) @link = sufia.show_single_use_link_path(@su.downloadKey) respond_to do |format| format.html format.js {render :js => @link} end end |
#show ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/single_use_link_controller.rb', line 45 def show link = lookup_hash #grab the item id id = link.itemId #check to make sure the path matches not_found if link.path != sufia.generic_file_path(id) #show the file @generic_file = GenericFile.load_instance_from_solr(id) @terms = @generic_file.terms_for_display # 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 = SingleUseLink.create_download(id) @download_link = sufia.download_single_use_link_path(@su.downloadKey) end |