BodyPart

public struct BodyPart

Object encapsulating a singular part of a multipart form.

  • Initialize a BodyPart instance.

    Declaration

    Swift

    public init?(key: String, value: Any)

    Parameters

    key

    The body part identifier.

    value

    The value of the BodyPart.

  • Initialize a BodyPart instance.

    Declaration

    Swift

    public init(key: String, data: Data, mimeType: String? = nil, fileName: String? = nil)

    Parameters

    key

    The body part identifier.

    data

    The data of the BodyPart.

    mimeType

    The MIME type.

    fileType

    The data’s file name.

  • Construct the content of the BodyPart.

    Declaration

    Swift

    public func content() throws -> Data

    Return Value

    Returns a Data object consisting of the header and data.