You are viewing documentation for a previous version of this software.

Switch to the latest stable version.

MultipartFormData


CLASS

MultipartFormData

Swift
1public class MultipartFormData

A helper for building out multi-part form data for upload

Properties

boundary

Swift
1public let boundary: String

Methods

init(boundary:)

Swift
1public init(boundary: String)

Designated initializer

  • Parameter boundary: The boundary to use between parts of the form.

Parameters

NameDescription
boundaryThe boundary to use between parts of the form.

init()

Swift
1public convenience init()

Convenience initializer which uses a pre-defined boundary

appendPart(string:name:)

Swift
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

NameDescription
stringThe string to append
nameThe name of the part to pass along to the server

appendPart(data:name:contentType:filename:)

Swift
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

NameDescription
dataThe data to append
nameThe 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:)

Swift
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

NameDescription
inputStreamThe input stream to append.
contentLengthLength of the input stream data.
nameThe 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()

Swift
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.

Feedback

Edit on GitHub

Forums