1
totalBytesExpectedToRead返回-1,即使內容長度有一個值斯威夫特 - Alamofire totalBytesExpectedToRead返回-1,即使內容長度設置
我發現這裏的計算器一樣problem但沒有回答
這裏是我的代碼:
Alamofire.download(.POST, urlString, headers: headers, destination: destination)
.progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
print("totalBytesRead: \(totalBytesRead)")
print("totalBytesExpectedToRead: \(totalBytesExpectedToRead)\n\n")
}
.response { request, response, data, error in
}
服務器響應:
Access-Control-Allow-Origin →*
Access-Control-Expose-Headers →Link
Connection →keep-alive
Content-Length →163
Content-Type →application/json; charset=utf-8
Date →Tue, 04 Oct 2016 07:12:56 GMT
結果:
totalBytesRead: 1211
totalBytesExpectedToRead: -1
我會檢查服務器。感謝@弗朗索瓦你的答案 – acmel067