Skip to content

Instance Method

serialize(parts:boundary:into:)

Serializes the MultipartForm into a ByteBuffer.
func serialize(parts: [MultipartPart], boundary: String, into buffer: inout ByteBuffer) throws

Parameters

parts

One or more MultipartParts to serialize into Data.

boundary

Multipart boundary to use for encoding. This must not appear anywhere in the encoded data.

buffer

Buffer to write to.

Discussion

var buffer = ByteBuffer()
try MultipartSerializer().serialize(parts: [part], boundary: "123", into: &buffer)
print(String(buffer: buffer)) // multipart-encoded

Throws

Any errors that may occur during serialization.