Creates a new parser which parses io with multipart boundary boundary.
True if #next
can be called legally.
Parses the next form-data part and yields field name, io, FileMetadata
, and raw headers.
Reference
Reference
Object
Object
Creates a new parser which parses io with multipart boundary boundary.
Parses the next form-data part and yields field name, io, FileMetadata
, and raw headers.
This method yields once instead of returning the values, because the IO object yielded to the block is only valid while the block is executing. The IO object will be closed as soon as the block returns. To store the content of the body part for longer than the block, the IO must be read into memory.
require "http" form_data = "--aA40\r\nContent-Disposition: form-data; name=\"field1\"; filename=\"foo.txt\"; size=13\r\nContent-Type: text/plain\r\n\r\nfield data\r\n--aA40--" parser = HTTP::FormData::Parser.new(IO::Memory.new(form_data), "aA40") parser.next do |part| part.name # => "field1" part.body.gets_to_end # => "field data" part.filename # => "foo.txt" part.size # => 13 part.headers["Content-Type"] # => "text/plain" end
© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/HTTP/FormData/Parser.html