FormDataDecoder

public final class FormDataDecoder

Decodes Decodable types from multipart/form-data encoded Data.

See RFC#2388 for more information about multipart/form-data encoding.

Seealso MultipartParser for more information about the multipart encoding.

  • Creates a new FormDataDecoder.

    Declaration

    Swift

    public init()
  • Decodes a Decodable item from Data using the supplied boundary.

    let foo = try FormDataDecoder().decode(Foo.self, from: data, boundary: "123")
    

    Throws

    Any errors decoding the model with Codable or parsing the data.

    Declaration

    Swift

    public func decode<D>(_ decodable: D.Type, from data: LosslessDataConvertible, boundary: LosslessDataConvertible) throws -> D where D: Decodable

    Parameters

    encodable

    Generic Decodable type.

    boundary

    Multipart boundary to used in the encoding.

    Return Value

    An instance of the decoded type D.