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
dataThe data to encode into the multipart form data.
nameThe name to associate with the data in the
Content-DispositionHTTP header.fileNameThe filename to associate with the data in the
Content-DispositionHTTP header.typeThe MIME type to associate with the data in the
Content-TypeHTTP header.showExtensionWhether 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
dataThe data to encode into the multipart form data.
nameThe name to associate with the data in the
Content-DispositionHTTP header.typeThe MIME type to associate with the data content type in the
Content-TypeHTTP 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
urlThe URL of the file whose content will be encoded into the multipart form data.
nameThe name to associate with the file content in the
Content-DispositionHTTP header.typeThe MIME type to associate with the file content in the
Content-TypeHTTP 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
valueThe value to encode into the multipart form data.
forKeyThe key to associate with the value in the
Content-DispositionHTTP header. -
Builds MultipartFormData object.
Declaration
Swift
public func build() -> (MultipartFormData) -> Void
View on GitHub
MultipartFormDataBuilder Class Reference