gitlab-org--gitlab-foss/app/controllers/files_controller.rb

18 lines
377 B
Ruby
Raw Normal View History

2013-02-11 14:31:19 -05:00
class FilesController < ApplicationController
def download
2013-02-15 02:51:21 -05:00
note = Note.find(params[:id])
uploader = note.attachment
2013-02-15 02:51:21 -05:00
if uploader.file_storage?
if can?(current_user, :read_project, note.project)
send_file uploader.file.path, disposition: 'attachment'
else
not_found!
end
2013-02-15 02:51:21 -05:00
else
redirect_to uploader.url
2013-02-15 02:51:21 -05:00
end
2013-02-11 14:31:19 -05:00
end
end