MultipartFormDataBuilder

open class MultipartFormDataBuilder

Undocumented

  • Initialize MultipartFormDataBuilder

    Declaration

    Swift

    public init()
  • Adds a body part from the data and appends it to the multipart form data object.

    The body part data will be encoded using the following format:

    • Content-Disposition: form-data; name=#{name}; filename=#{filename} (HTTP Header)
    • Content-Type: #{mimeType} (HTTP Header)
    • Encoded file data
    • Multipart form boundary

    Declaration

    Swift

    public func add(data: Data, name: String, fileName: String, mimeType type: MIMETypes, showExtension: Bool = false)

    Parameters

    data

    The data to encode into the multipart form data.

    name

    The name to associate with the data in the Content-Disposition HTTP header.

    fileName

    The filename to associate with the data in the Content-Disposition HTTP header.

    type

    The MIME type to associate with the data in the Content-Type HTTP header.

    showExtension

    Whether should extension be added to filename.

  • Adds a body part from the data and appends it to the multipart form data object.

    The body part data will be encoded using the following format:

    • Content-Disposition: form-data; name=#{name} (HTTP Header)
    • Content-Type: #{generated mimeType} (HTTP Header)
    • Encoded data
    • Multipart form boundary

    Declaration

    Swift

    public func add(data: Data, name: String, mimeType type: MIMETypes)

    Parameters

    data

    The data to encode into the multipart form data.

    name

    The name to associate with the data in the Content-Disposition HTTP header.

    type

    The MIME type to associate with the data content type in the Content-Type HTTP header.

  • Adds a body part from the file and appends it to the multipart form data object. The body part data will be encoded using the following format:

    • Content-Disposition: form-data; name=#{name}; filename=#{filename} (HTTP Header)
    • Content-Type: #{mimeType} (HTTP Header)
    • Encoded file data
    • Multipart form boundary

    Declaration

    Swift

    public func add(file url: URL, name: String, mimeType type: MIMETypes)

    Parameters

    url

    The URL of the file whose content will be encoded into the multipart form data.

    name

    The name to associate with the file content in the Content-Disposition HTTP header.

    type

    The MIME type to associate with the file content in the Content-Type HTTP header.

  • Creates a body part from the data and appends it to the multipart form data object.

    The body part data will be encoded using the following format:

    • Content-Disposition: form-data; name=#{key} (HTTP Header)
    • Encoded data
    • Multipart form boundary

    Declaration

    Swift

    public func addParam(_ value: String, for key: String)

    Parameters

    value

    The value to encode into the multipart form data.

    forKey

    The key to associate with the value in the Content-Disposition HTTP header.

  • Builds MultipartFormData object.

    Declaration

    Swift

    public func build() -> (MultipartFormData) -> Void