|
|
@@ -126,44 +126,6 @@ open class MultipartFormData {
|
|
|
|
|
|
// MARK: - Body Parts
|
|
|
|
|
|
- /// 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=#{name}` (HTTP Header)
|
|
|
- /// - Encoded data
|
|
|
- /// - Multipart form boundary
|
|
|
- ///
|
|
|
- /// - parameter data: The data to encode into the multipart form data.
|
|
|
- /// - parameter name: The name to associate with the data in the `Content-Disposition` HTTP header.
|
|
|
- public func append(_ data: Data, withName name: String) {
|
|
|
- let headers = contentHeaders(withName: name)
|
|
|
- let stream = InputStream(data: data)
|
|
|
- let length = UInt64(data.count)
|
|
|
-
|
|
|
- append(stream, withLength: length, headers: headers)
|
|
|
- }
|
|
|
-
|
|
|
- /// 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=#{name}` (HTTP Header)
|
|
|
- /// - `Content-Type: #{generated mimeType}` (HTTP Header)
|
|
|
- /// - Encoded data
|
|
|
- /// - Multipart form boundary
|
|
|
- ///
|
|
|
- /// - parameter data: The data to encode into the multipart form data.
|
|
|
- /// - parameter name: The name to associate with the data in the `Content-Disposition` HTTP header.
|
|
|
- /// - parameter mimeType: The MIME type to associate with the data content type in the `Content-Type` HTTP header.
|
|
|
- public func append(_ data: Data, withName name: String, mimeType: String) {
|
|
|
- let headers = contentHeaders(withName: name, mimeType: mimeType)
|
|
|
- let stream = InputStream(data: data)
|
|
|
- let length = UInt64(data.count)
|
|
|
-
|
|
|
- append(stream, withLength: length, headers: headers)
|
|
|
- }
|
|
|
-
|
|
|
/// 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:
|
|
|
@@ -177,7 +139,7 @@ open class MultipartFormData {
|
|
|
/// - parameter name: The name to associate with the data in the `Content-Disposition` HTTP header.
|
|
|
/// - parameter fileName: The filename to associate with the data in the `Content-Disposition` HTTP header.
|
|
|
/// - parameter mimeType: The MIME type to associate with the data in the `Content-Type` HTTP header.
|
|
|
- public func append(_ data: Data, withName name: String, fileName: String, mimeType: String) {
|
|
|
+ public func append(_ data: Data, withName name: String, fileName: String? = nil, mimeType: String? = nil) {
|
|
|
let headers = contentHeaders(withName: name, fileName: fileName, mimeType: mimeType)
|
|
|
let stream = InputStream(data: data)
|
|
|
let length = UInt64(data.count)
|