         if let bodyPartError = bodyPartError {
             throw bodyPartError
         }
-
 
         if FileManager.default.fileExists(atPath: fileURL.path) {
             let failureReason = "A file already exists at the given file URL: \(fileURL)"


    // MARK: - Private - Body Part Encoding

    private func encodeBodyPart(_ bodyPart: BodyPart) throws -> Data {
        var encoded = Data()

        let initialData = bodyPart.hasInitialBoundary ? initialBoundaryData() : encapsulatedBoundaryData()
        encoded.append(initialData)

        let headerData = encodeHeaderData(for: bodyPart)
        encoded.append(headerData)

        let bodyStreamData = try encodeBodyStreamData(for: bodyPart)
        encoded.append(bodyStreamData)

        if bodyPart.hasFinalBoundary {


    // MARK: - Private - Content Headers

    private func contentHeaders(withName name: String, fileName: String? = nil, mimeType: String? = nil) -> [String: String] {
        var disposition = "form-data; name=\"\(name)\""
        if let fileName = fileName { disposition += "; filename=\"\(fileName)\"" }

        var headers = ["Content-Disposition": disposition]
        if let mimeType = mimeType { headers["Content-Type"] = mimeType }

        return headers
    }

    // MARK: - Private - Boundary Encoding
