diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-26 13:55:46 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-26 13:55:46 +0000 |
commit | ed15b5061242cb70b2e11c3d08c727e07aa932a8 (patch) | |
tree | c244874d236a06a17bd649952508fd52e3caf690 /lib | |
parent | 900b14e4e77af2ca4589088d8cebc00fd6ebc1e1 (diff) | |
download | gitlab-ce-ed15b5061242cb70b2e11c3d08c727e07aa932a8.tar.gz |
Add latest changes from gitlab-org/security/gitlab@13-0-stable-ee
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/group_import.rb | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/api/group_import.rb b/lib/api/group_import.rb index ed52506de14..ec51c2f44c3 100644 --- a/lib/api/group_import.rb +++ b/lib/api/group_import.rb @@ -4,6 +4,8 @@ module API class GroupImport < Grape::API MAXIMUM_FILE_SIZE = 50.megabytes.freeze + helpers Helpers::FileUploadHelpers + helpers do def parent_group find_group!(params[:parent_id]) if params[:parent_id].present? @@ -48,29 +50,20 @@ module API params do requires :path, type: String, desc: 'Group path' requires :name, type: String, desc: 'Group name' + requires :file, type: ::API::Validations::Types::WorkhorseFile, desc: 'The group export file to be imported' optional :parent_id, type: Integer, desc: "The ID of the parent group that the group will be imported into. Defaults to the current user's namespace." - optional 'file.path', type: String, desc: 'Path to locally stored body (generated by Workhorse)' - optional 'file.name', type: String, desc: 'Real filename as send in Content-Disposition (generated by Workhorse)' - optional 'file.type', type: String, desc: 'Real content type as send in Content-Type (generated by Workhorse)' - optional 'file.size', type: Integer, desc: 'Real size of file (generated by Workhorse)' - optional 'file.md5', type: String, desc: 'MD5 checksum of the file (generated by Workhorse)' - optional 'file.sha1', type: String, desc: 'SHA1 checksum of the file (generated by Workhorse)' - optional 'file.sha256', type: String, desc: 'SHA256 checksum of the file (generated by Workhorse)' end post 'import' do authorize_create_group! require_gitlab_workhorse! - - uploaded_file = UploadedFile.from_params(params, :file, ImportExportUploader.workhorse_local_upload_path) - - bad_request!('Unable to process group import file') unless uploaded_file + validate_file! group_params = { path: params[:path], name: params[:name], parent_id: params[:parent_id], visibility_level: closest_allowed_visibility_level, - import_export_upload: ImportExportUpload.new(import_file: uploaded_file) + import_export_upload: ImportExportUpload.new(import_file: params[:file]) } group = ::Groups::CreateService.new(current_user, group_params).execute |