gitlab-org--gitlab-foss/app/controllers/projects/uploads_controller.rb
Kamil Trzcinski 263717d70c Do not perform hard check (presence of file on storage)
Instead perform soft check (the column set to indicate that file does exist)
2017-09-19 16:41:28 +02:00

39 lines
840 B
Ruby

class Projects::UploadsController < Projects::ApplicationController
include UploadsActions
skip_before_action :project, :repository,
if: -> { action_name == 'show' && image_or_video? }
before_action :authorize_upload_file!, only: [:create]
private
def uploader
return @uploader if defined?(@uploader)
namespace = params[:namespace_id]
id = params[:project_id]
file_project = Project.find_by_full_path("#{namespace}/#{id}")
if file_project.nil?
@uploader = nil
return
end
@uploader = FileUploader.new(file_project, params[:secret])
@uploader.retrieve_from_store!(params[:filename])
@uploader
end
def image_or_video?
uploader && uploader.exists? && uploader.image_or_video?
end
def uploader_class
FileUploader
end
alias_method :model, :project
end