summaryrefslogtreecommitdiff
path: root/app/controllers/files_controller.rb
blob: 7937454810d9929279b9e84fcc86552d5aa882a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class FilesController < ApplicationController
  def download
    note = Note.find(params[:id])
    uploader = note.attachment

    if uploader.file_storage?
      if can?(current_user, :read_project, note.project)
        send_file uploader.file.path, disposition: 'attachment'
      else
        not_found!
      end
    else
      redirect_to uploader.url
    end
  end
end