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