app/controllers/hyrax/downloads_controller.rb in hyrax-2.1.0.beta1 vs app/controllers/hyrax/downloads_controller.rb in hyrax-2.1.0.beta2
- old
+ new
@@ -1,8 +1,9 @@
module Hyrax
class DownloadsController < ApplicationController
include Hydra::Controller::DownloadBehavior
+ include Hyrax::LocalFileDownloadsControllerBehavior
def self.default_content_path
:original_file
end
@@ -13,13 +14,11 @@
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
+ send_local_content
else
raise ActiveFedora::ObjectNotFoundError
end
end
@@ -53,10 +52,10 @@
# Overrides Hydra::Controller::DownloadBehavior#load_file, which is hard-coded to assume files are in BasicContainer.
# Override this method to change which file is shown.
# Loads the file specified by the HTTP parameter `:file`.
# If this object does not have a file by that name, return the default file
# as returned by {#default_file}
- # @return [ActiveFedora::File, String, NilClass] Returns the file from the repository or a path to a file on the local file system, if it exists.
+ # @return [ActiveFedora::File, File, NilClass] Returns the file from the repository or a path to a file on the local file system, if it exists.
def load_file
file_reference = params[:file]
return default_file unless file_reference
file_path = Hyrax::DerivativePath.derivative_path_for_reference(params[asset_param_key], file_reference)