MultipartFormData

public class MultipartFormData

Object encapsulating a multipart form.

  • String denoting the Content-Type of the request header.

    Declaration

    Swift

    public var contentType: String { get }
  • Initialize a MultipartFormData instance.

    Declaration

    Swift

    public init()
  • Append a new body part to the multipart form, where the original data is in a file described by the fileName string.

    Declaration

    Swift

    public func append(_ data: Data, withName: String, mimeType: String? = nil, fileName: String? = nil)

    Parameters

    Data

    The data of the body part.

    withName

    The name/key of the body part.

    mimeType

    The MIME type of the body part.

    fileName

    The name of the file the data came from.

    Return Value

    Returns a Data object encompassing the combined body parts.

  • Append a new body part to the multipart form, where the original data is in a url described by fileURL.

    Declaration

    Swift

    public func append(_ fileURL: URL, withName: String, mimeType: String? = nil)

    Parameters

    fileURL

    The url to extract the data from.

    withName

    The name/key of the body part.

    mimeType

    The MIME type of the body part.

    Return Value

    Returns a Data object encompassing the combined body parts.

  • Combine the multipart form body parts into a single Data object.

    Declaration

    Swift

    public func toData() throws -> Data

    Return Value

    Returns a Data object encompassing the combined body parts.