Class: Gitlab::ImportExport::RemoteStreamUpload
- Inherits:
-
Object
- Object
- Gitlab::ImportExport::RemoteStreamUpload
- Defined in:
- lib/gitlab/import_export/remote_stream_upload.rb
Defined Under Namespace
Classes: ChunkStream, StreamError
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(download_url:, upload_url:, options: {}) ⇒ RemoteStreamUpload
constructor
A new instance of RemoteStreamUpload.
Constructor Details
#initialize(download_url:, upload_url:, options: {}) ⇒ RemoteStreamUpload
Returns a new instance of RemoteStreamUpload.
12 13 14 15 16 17 |
# File 'lib/gitlab/import_export/remote_stream_upload.rb', line 12 def initialize(download_url:, upload_url:, options: {}) @download_url = download_url @upload_url = upload_url @upload_method = [:upload_method] || :post @upload_content_type = [:upload_content_type] || 'application/gzip' end |
Instance Method Details
#execute ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/gitlab/import_export/remote_stream_upload.rb', line 19 def execute receive_data(download_url) do |response, chunks| send_data(upload_url, response.content_length, chunks) do |response| if response.code != '200' raise StreamError.new("Invalid response code while uploading file. Code: #{response.code}", response.body) end end end end |