MultipartFormData
CLASS
MultipartFormData
1public class MultipartFormData
A helper for building out multi-part form data for upload
Properties
boundary
1public let boundary: String
Methods
init(boundary:)
1public init(boundary: String)
Designated initializer
Parameter boundary: The boundary to use between parts of the form.
Parameters
Name | Description |
---|---|
boundary | The boundary to use between parts of the form. |
init()
1public convenience init()
Convenience initializer which uses a pre-defined boundary
appendPart(string:name:)
1public func appendPart(string: String, name: String) throws
Appends the passed-in string as a part of the body.
Parameters:
string: The string to append
name: The name of the part to pass along to the server
Parameters
Name | Description |
---|---|
string | The string to append |
name | The name of the part to pass along to the server |
appendPart(data:name:contentType:filename:)
1public func appendPart(data: Data,
2 name: String,
3 contentType: String? = nil,
4 filename: String? = nil)
Appends the passed-in data as a part of the body.
Parameters:
data: The data to append
name: The name of the part to pass along to the server
contentType: [optional] The content type of this part. Defaults to nil.
filename: [optional] The name of the file for this part. Defaults to nil.
Parameters
Name | Description |
---|---|
data | The data to append |
name | The name of the part to pass along to the server |
contentType | [optional] The content type of this part. Defaults to nil. |
filename | [optional] The name of the file for this part. Defaults to nil. |
appendPart(inputStream:contentLength:name:contentType:filename:)
1public func appendPart(inputStream: InputStream,
2 contentLength: UInt64,
3 name: String,
4 contentType: String? = nil,
5 filename: String? = nil)
Appends the passed-in input stream as a part of the body.
Parameters:
inputStream: The input stream to append.
contentLength: Length of the input stream data.
name: The name of the part to pass along to the server
contentType: [optional] The content type of this part. Defaults to nil.
filename: [optional] The name of the file for this part. Defaults to nil.
Parameters
Name | Description |
---|---|
inputStream | The input stream to append. |
contentLength | Length of the input stream data. |
name | The name of the part to pass along to the server |
contentType | [optional] The content type of this part. Defaults to nil. |
filename | [optional] The name of the file for this part. Defaults to nil. |
encode()
1public func encode() throws -> Data
Encodes everything into the final form data to send to a server.
Returns: The final form data to send to a server.