debian-mirror-gitlab/lib/api/helpers/file_upload_helpers.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
474 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +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
2021-12-11 22:18:48 +05:30
filename && ImportExportUploader::EXTENSION_ALLOWLIST.include?(File.extname(filename).delete('.'))
2020-03-13 15:44:24 +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-13 15:44:24 +05:30
end
end
end
end