Vapor Documentation Beta

Class Multipart​Parser

public final class MultipartParser

Parses multipart-encoded Data into MultipartParts. Multipart encoding is a widely-used format for encoding/// web-form data that includes rich content like files. It allows for arbitrary data to be encoded in each part thanks to a unique delimiter "boundary" that is defined separately. This boundary is guaranteed by the client to not appear anywhere in the data.

multipart/form-data is a special case of multipart encoding where each part contains a Content-Disposition header and name. This is used by the FormDataEncoder and FormDataDecoder to convert Codable types to/from multipart data.

See Wikipedia for more information.

Seealso form-urlencoded encoding where delimiter boundaries are not required.

Initializers

init(boundary:​)

public init(boundary: String)

Creates a new MultipartParser.

Properties

on​Header

var onHeader: (String, String) -> ()

on​Body

var onBody: (inout ByteBuffer) -> ()

on​Part​Complete

var onPartComplete: () -> ()

Methods

execute(_:​)

public func execute(_ string: String) throws

execute(_:​)

public func execute<Data>(_ data: Data) throws where Data: DataProtocol

execute(_:​)

public func execute(_ buffer: ByteBuffer) throws