Instance Method
encode(_:boundary:)
Encodes an
Encodable item to String using the supplied boundary.func encode<E>(_ encodable: E, boundary: String) throws -> String where E : Encodable
Parameters
encodableGeneric
Encodableitem.boundaryMultipart boundary to use for encoding. This must not appear anywhere in the encoded data.
Return Value
multipart/form-data-encoded String.
Discussion
let a = Foo(string: "a", int: 42, double: 3.14, array: [1, 2, 3])
let data = try FormDataEncoder().encode(a, boundary: "123")
Throws
Any errors encoding the model with Codable or serializing the data.