debian-mirror-gitlab/app/controllers/projects/uploads_controller.rb

40 lines
845 B
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class Projects::UploadsController < Projects::ApplicationController
2017-08-17 22:00:37 +05:30
include UploadsActions
2015-04-26 12:48:37 +05:30
2017-08-17 22:00:37 +05:30
skip_before_action :project, :repository,
if: -> { action_name == 'show' && image_or_video? }
2015-04-26 12:48:37 +05:30
2017-08-17 22:00:37 +05:30
before_action :authorize_upload_file!, only: [:create]
2015-04-26 12:48:37 +05:30
2016-06-02 11:05:42 +05:30
private
2015-04-26 12:48:37 +05:30
def uploader
return @uploader if defined?(@uploader)
namespace = params[:namespace_id]
id = params[:project_id]
2017-08-17 22:00:37 +05:30
file_project = Project.find_by_full_path("#{namespace}/#{id}")
2015-04-26 12:48:37 +05:30
if file_project.nil?
2015-09-11 14:41:01 +05:30
@uploader = nil
2015-04-26 12:48:37 +05:30
return
end
@uploader = FileUploader.new(file_project, params[:secret])
@uploader.retrieve_from_store!(params[:filename])
@uploader
end
2016-08-24 12:49:21 +05:30
def image_or_video?
uploader && uploader.file.exists? && uploader.image_or_video?
2015-04-26 12:48:37 +05:30
end
2017-08-17 22:00:37 +05:30
def uploader_class
FileUploader
end
alias_method :model, :project
2015-04-26 12:48:37 +05:30
end