Module: CurationConcerns::DownloadBehavior

Extended by:
ActiveSupport::Concern
Includes:
Hydra::Controller::DownloadBehavior
Included in:
SingleUseLinksViewerControllerBehavior, DownloadsController
Defined in:
app/controllers/concerns/curation_concerns/download_behavior.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#showObject

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



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/concerns/curation_concerns/download_behavior.rb', line 15

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
    render_404
  end
end