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

45 lines
1.2 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2015-04-26 12:48:37 +05:30
class Projects::UploadsController < Projects::ApplicationController
2017-08-17 22:00:37 +05:30
include UploadsActions
2018-11-08 19:23:39 +05:30
include WorkhorseRequest
2015-04-26 12:48:37 +05:30
2018-03-17 18:26:18 +05:30
# These will kick you out if you don't have access.
2017-08-17 22:00:37 +05:30
skip_before_action :project, :repository,
2019-12-21 20:55:43 +05:30
if: -> { action_name == 'show' && embeddable? }
2015-04-26 12:48:37 +05:30
2018-11-08 19:23:39 +05:30
before_action :authorize_upload_file!, only: [:create, :authorize]
before_action :verify_workhorse_api!, only: [:authorize]
2015-04-26 12:48:37 +05:30
2021-01-03 14:25:43 +05:30
feature_category :not_owned
2016-06-02 11:05:42 +05:30
private
2018-03-17 18:26:18 +05:30
def upload_model_class
Project
2015-04-26 12:48:37 +05:30
end
2017-08-17 22:00:37 +05:30
def uploader_class
FileUploader
end
2018-03-17 18:26:18 +05:30
def find_model
return @project if @project
namespace = params[:namespace_id]
id = params[:project_id]
Project.find_by_full_path("#{namespace}/#{id}")
end
2020-03-09 13:42:32 +05:30
# Overrides ApplicationController#build_canonical_path since there are
# multiple routes that match project uploads:
# https://gitlab.com/gitlab-org/gitlab/issues/196396
def build_canonical_path(project)
return super unless action_name == 'show'
return super unless params[:secret] && params[:filename]
show_namespace_project_uploads_url(project.namespace.to_param, project.to_param, params[:secret], params[:filename])
end
2015-04-26 12:48:37 +05:30
end