Class: Hyrax::DownloadsController

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

Direct Known Subclasses

SingleUseLinksViewerController

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_content_pathObject



5
6
7
# File 'app/controllers/hyrax/downloads_controller.rb', line 5

def self.default_content_path
  :original_file
end

Instance Method Details

#showObject

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



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/hyrax/downloads_controller.rb', line 11

def show
  case file
  when ActiveFedora::File
    # For original files that are stored in fedora
    super
  when String
    # For derivatives stored on the local file system
    response.headers['Accept-Ranges'] = 'bytes'
    response.headers['Content-Length'] = File.size(file).to_s
    send_file file, derivative_download_options
  else
    raise ActiveFedora::ObjectNotFoundError
  end
end