미리 지정된 URL과 AFNetworking 3.0
을 사용하여 S3에서 이미지를 가져 오는 데 문제가 있습니다. NSMutableURLRequest
과 NSURLSession
을 사용하여 이미지를 얻을 수 있지만 AFHTTPSessionManager
과 같은 NSMutableURLRequest
을 사용할 때 403 오류가 발생합니다. (실제로는 403 오류를주는 setImageWithURLRequest를 호출하여 이미지를로드하려고하지만 을 사용하여이 코드를 작성하여 문제를 디버그하려고했습니다.) AFNetworking
과 함께 무엇을 잘못 수행 할 수 있습니까?NSURLSession에서 GET이 성공했지만 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()