Class: Daytona::MultipartDownloadStreamParser
- Inherits:
-
Object
- Object
- Daytona::MultipartDownloadStreamParser
- Defined in:
- lib/daytona/file_transfer.rb
Instance Attribute Summary collapse
-
#boundary_token ⇒ Object
writeonly
Sets the attribute boundary_token.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#part_bytes_emitted ⇒ Object
readonly
Returns the value of attribute part_bytes_emitted.
-
#part_total_bytes ⇒ Object
readonly
Returns the value of attribute part_total_bytes.
Instance Method Summary collapse
- #<<(chunk) ⇒ Object
-
#finish! ⇒ Object
Raises if the response ended before the closing multipart boundary, so truncations surface as typed errors instead of silently short downloads.
-
#initialize(&on_file_chunk) ⇒ MultipartDownloadStreamParser
constructor
A new instance of MultipartDownloadStreamParser.
Constructor Details
#initialize(&on_file_chunk) ⇒ MultipartDownloadStreamParser
Returns a new instance of MultipartDownloadStreamParser.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/daytona/file_transfer.rb', line 24 def initialize(&on_file_chunk) @on_file_chunk = on_file_chunk @boundary_token = nil @buffer = String.new.b @state = :preamble @part_name = nil @part_total_bytes = nil @part_bytes_emitted = 0 @error_buffer = String.new.b end |
Instance Attribute Details
#boundary_token=(value) ⇒ Object (writeonly)
Sets the attribute boundary_token
22 23 24 |
# File 'lib/daytona/file_transfer.rb', line 22 def boundary_token=(value) @boundary_token = value end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
19 20 21 |
# File 'lib/daytona/file_transfer.rb', line 19 def @error_message end |
#part_bytes_emitted ⇒ Object (readonly)
Returns the value of attribute part_bytes_emitted.
21 22 23 |
# File 'lib/daytona/file_transfer.rb', line 21 def part_bytes_emitted @part_bytes_emitted end |
#part_total_bytes ⇒ Object (readonly)
Returns the value of attribute part_total_bytes.
20 21 22 |
# File 'lib/daytona/file_transfer.rb', line 20 def part_total_bytes @part_total_bytes end |
Instance Method Details
#<<(chunk) ⇒ Object
35 36 37 38 |
# File 'lib/daytona/file_transfer.rb', line 35 def <<(chunk) @buffer << chunk.b process! end |
#finish! ⇒ Object
Raises if the response ended before the closing multipart boundary, so truncations surface as typed errors instead of silently short downloads.
42 43 44 45 46 47 |
# File 'lib/daytona/file_transfer.rb', line 42 def finish! process! return if @state == :done raise Sdk::Error, "Truncated multipart response: closing boundary not received (state=#{@state})" end |