Class: DownloadsController

Inherits:
ApplicationController show all
Includes:
Hydra::RepositoryController, MediaShelf::ActiveFedoraHelper
Defined in:
vendor/plugins/hydra_repository/app/controllers/downloads_controller.rb

Instance Method Summary (collapse)

Methods included from Hydra::RepositoryController

#downloadables, included, #solr_name

Methods included from MediaShelf::ActiveFedoraHelper

#load_af_instance_from_solr, #retrieve_af_model

Methods inherited from ApplicationController

#current_user, #default_html_head, #error, #extra_head_content, #javascript_includes, #stylesheet_links, #user_class

Methods included from HydraAccessControlsHelper

#editor?, #reader?, #test_permission

Instance Method Details

- (Object) index

Note: Actual downloads are handled by the index method insead of the show method in order to avoid ActionController being clever with the filenames/extensions/formats. To download a datastream, pass the datastream id as ?document_id=#dsid in the url



12
13
14
15
16
17
18
19
20
21
# File 'vendor/plugins/hydra_repository/app/controllers/downloads_controller.rb', line 12

def index
  fedora_object = ActiveFedora::Base.load_instance(params[:asset_id])
  if params[:download_id]
    @datastream = fedora_object.datastreams[params[:download_id]]
    send_data @datastream.content, :filename=>@datastream.label, :type=>@datastream.attributes["mimeType"]
    #send_data( Fedora::Repository.instance.fetch_custom(params[:document_id], "datastreams/#{datastream_id}/content") )
  else
    @datastreams = downloadables( fedora_object )
  end
end