Welcome to mirror list, hosted at ThFree Co, Russian Federation.

file_upload.rb « file_acquisition_strategies « gitlab_projects « import « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8bee3067d6cb9b7fb3a88e3a8f93555a98481ab9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

module Import
  module GitlabProjects
    module FileAcquisitionStrategies
      class FileUpload
        include ActiveModel::Validations

        validate :uploaded_file

        def initialize(current_user: nil, params:)
          @params = params
        end

        def project_params
          @project_params ||= @params.slice(:file)
        end

        def file
          @file ||= @params[:file]
        end

        private

        def uploaded_file
          return if file.present? && file.is_a?(UploadedFile)

          errors.add(:file, 'must be uploaded')
        end
      end
    end
  end
end