Vapor Documentation Beta

Class Multipart​Serializer

public final class MultipartSerializer

Serializes MultipartForms to Data.

See MultipartParser for more information about the multipart encoding.

Initializers

init()

public init()

Creates a new MultipartSerializer.

Methods

serialize(parts:​boundary:​)

public func serialize(parts: [MultipartPart], boundary: String) throws -> String

serialize(parts:​boundary:​into:​)

public func serialize(parts: [MultipartPart], boundary: String, into buffer: inout ByteBuffer) throws

Serializes the MultipartForm to data.

let data = try MultipartSerializer().serialize(parts: [part], boundary: "123")
print(data) // multipart-encoded

Parameters

parts [Multipart​Part]

One or more MultipartParts to serialize into Data.

boundary String

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

Throws

Any errors that may occur during serialization.

Returns

multipart-encoded Data.