mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-07-25 16:03:48 +00:00
17 lines
474 B
Ruby
17 lines
474 B
Ruby
# frozen_string_literal: true
|
|
|
|
module API
|
|
module Helpers
|
|
module FileUploadHelpers
|
|
def file_is_valid?
|
|
filename = params[:file]&.original_filename
|
|
filename && ImportExportUploader::EXTENSION_ALLOWLIST.include?(File.extname(filename).delete('.'))
|
|
end
|
|
|
|
def validate_file!
|
|
render_api_error!({ error: _('You need to upload a GitLab project export archive (ending in .gz).') }, 422) unless file_is_valid?
|
|
end
|
|
end
|
|
end
|
|
end
|