0
我無法使用預先註冊的url從S3獲取圖像,並且AFNetworking 3.0
。我可以使用NSMutableURLRequest
和NSURLSession
來獲取圖像,但是當我使用AFHTTPSessionManager
和NSMutableURLRequest
時,出現403錯誤。 (我真的想通過調用setImageWithURLRequest來加載圖片,這也給了我一個403錯誤,但我寫了這個代碼,它使用AFHTTPSessionManager
來嘗試調試這個問題。)我怎麼會在AFNetworking
上做錯?GET成功使用NSURLSession,但使用AFHTTPSessionManager失敗
let request = NSMutableURLRequest()
request.HTTPMethod = "GET"
request.URL = coverPhotoUrl // A presigned url to an image on S3
// The operation succeeds if I uncomment the NSURLSession line
// and comment out the AFHTTPSessionManager line.
//NSURLSession.sharedSession().dataTaskWithRequest(request) {
AFHTTPSessionManager().dataTaskWithRequest(request) {
date, response, error in
if let error = error {
Log.error?.message("request failed: \(error.localizedDescription)")
} else {
Log.debug?.message("request succeeded.")
}
}
.resume()