Class: WorkDownloaderController

Inherits:
ApplicationController show all
Defined in:
app/controllers/work_downloader_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#new_session_path

Instance Method Details

#downloadObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/work_downloader_controller.rb', line 3

def download
  work = Work.find(params[:id])
  if current_user && work.editable_by?(current_user)
    file_name = params[:filename]
    mode = work.approved? ? "postcuration" : "precuration"
    service = S3QueryService.new(work, mode)
    uri = service.file_url(file_name)
    redirect_to uri
  else
    Honeybadger.notify("Can not download work: #{work.id} is not editable by #{current_user.uid}")
    redirect_to root_path, notice: I18n.t("works.download.privs")
  end
end