Jelajahi Sumber

Condensed 3 MultipartFormData data APIs into 1 (#2766)

Ernesto Rivera 6 tahun lalu
induk
melakukan
218561deed
1 mengubah file dengan 1 tambahan dan 39 penghapusan
  1. 1 39
      Source/MultipartFormData.swift

+ 1 - 39
Source/MultipartFormData.swift

@@ -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)