MultipartBodyPart
public struct MultipartBodyPart : Hashable
Structure representing part in multipart/form-data request.
These parts must have valid headers according
to RFC-7578.
Everything passed to it is converted to InputStream
in order to limit memory usage when sending files to a server.
-
Creates a new instance with custom headers and any input stream.
Declaration
Swift
public init(headers: [String : String], inputStream: InputStream)Parameters
headersHTTP headers specific for the part, these are not validated locally and must be correct according to RFC-7578.
inputStreamAny byte stream.
-
Creates a new instance from key-value or HTTP parameter.
Declaration
Swift
public init(name: String, value: String)Parameters
nameName of the parameter used in
Content-Dispositionheader.valueString value of the parameter set as a body.
-
Creates a new instance with custom headers and data as body.
Declaration
Swift
public init(headers: [String : String], data: Data)Parameters
headersHTTP headers specific for the part, these are not validated locally and must be correct according to RFC-7578.
dataBytes sent as a part body.
-
Creates a new instance with file URL used to be converted to body.
Throws
APIError.multipartStreamCannotBeOpenedif stream was not created from the file.Declaration
Swift
public init(name: String, url: URL) throwsParameters
nameName of the parameter used in
Content-Dispositionheader.urlURL to a local file.
View on GitHub
MultipartBodyPart Structure Reference