2020-03-09 13:42:32 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Helpers
|
|
|
|
module FileUploadHelpers
|
|
|
|
def file_is_valid?
|
2020-04-08 14:13:33 +05:30
|
|
|
filename = params[:file]&.original_filename
|
|
|
|
filename && ImportExportUploader::EXTENSION_WHITELIST.include?(File.extname(filename).delete('.'))
|
2020-03-09 13:42:32 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def validate_file!
|
2020-04-08 14:13:33 +05:30
|
|
|
render_api_error!({ error: _('You need to upload a GitLab project export archive (ending in .gz).') }, 422) unless file_is_valid?
|
2020-03-09 13:42:32 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|