2016-12-02 63 views
2

我的应用程序在除iphone 6s plus之外的所有设备上都使用alamofire 4.0.1完美上传照片(在iPhone 4s,5.5s,6,7,7plus上使用9.2和10.1版本进行测试)Alamofire仅在iPhone 6s上载时崩溃

 let image = profileimage 
     Alamofire.upload(multipartFormData: { multipartFormData in 
       // import image to request 
       if let imageData = UIImageJPEGRepresentation(image!, 1) { 

        multipartFormData.append(imageData, withName: "user_profile.profile_picture", fileName: "profile_picture"+NSUUID().uuidString, mimeType: "image/png") 
       }  
      }, 
      usingThreshold: SessionManager.multipartFormDataEncodingMemoryThreshold, 
      to: baseURL+String(currentUser.id)+"/", 
      method: .put, 
      headers: headers, 
      encodingCompletion: { encodingResult in 
       switch encodingResult { 
       case .success(let upload, _, _): 
        upload.responseJSON { response in 
         let user = createUserFromJSON(response.result.value as! NSDictionary) //crashes here, response is nil 
         completion(user, nil) 
        } 
       case .failure(let encodingError): 
        let error = encodingError 
        completion(nil, error) 
       } 
     }) 

在iPhone 6S再加上它崩溃与此:

2016-12-02 13:26:04.391264 app[22207:366529] [] nw_socket_get_input_frames recvmsg(fd 14, 1024 bytes): [54] Connection reset by peer 
2016-12-02 13:26:04.393678 app[22207:366529] [] nw_endpoint_flow_prepare_output_frames [3.1 52.17.90.251:443 ready socket-flow (satisfied)] Failed to use 1 frames, marking as failed 
2016-12-02 13:26:04.394564 app[22207:366529] [] nw_socket_write_close shutdown(14, SHUT_WR): [57] Socket is not connected 
2016-12-02 13:26:04.394945 app[22207:366529] [] nw_endpoint_flow_service_writes [3.1 52.17.90.251:443 ready socket-flow (satisfied)] Write request has 0 frame count, 0 byte count 
2016-12-02 13:26:04.396875 app[22207:366613] [] __tcp_connection_write_eof_block_invoke Write close callback received error: [89] Operation canceled 
+1

哪个ios版本在iPhone 6 plus? –

+0

它在IOS版本10.1和9.2上崩溃 – Stav1

+0

你已经测试了你的应用程序的所有这些设备,意味着你正在使用iPhone模拟器或实际设备?典型的图像有多大? –

回答

0

这不得不无关Alamofire!这是NGINX的最大文件上传大小。我发现通过打印responseString而不是JSON。它说“请求实体太大”。

  upload.responseString { response in 
      print(response.result.value) 
      }