2017-05-05 4 views
0
appName[8121:97068] 8121: CFNetwork internal error (0xc01a:/BuildRoot/Library/Caches/com.apple.xbs/Sources/CFNetwork_Sim/CFNetwork-808.2.16/Loading/URLConnectionLoader.cpp:304) 

私はチャットアプリを持っている、と私は他人にイメージを送りたい。
CFNetworkは内部エラー(0xc01a:/BuildRoot/Library/Caches/com.apple.xbs/Sources/CFNetwork_Sim/CFNetwork-808.2.16/Loading/URLConnectionLoader.cpp:304)

I:IPhone;その他:シミュレータ

カメラで写真を撮って「この写真を使う」を押すと、他の人にURLを送信して画像をサーバーにアップロードします。
他はすぐにurlメッセージを受信し、私はこのイメージを表示するためにsdWebimageを使用します。
しかし、画像を受信すると、画像要求の印刷ログのエラーが発生します。
ログこの画像は存在しません。
イメージがアップロードされていて、サーバーにこのイメージがないかどうかにかかわらず、このイメージのダウンロードエラーを確認していません。
エラーを10秒間ダウンロードした後、この状況を回避したり、ダウンロードを再設定する機能はありますか?

これは私のsd_imageのFUNCです:

cell.photoImageView.sd_setImage(with: url, placeholderImage: nil, options: .progressiveDownload, progress: nil 
         , completed: { (image, error, cacheType, url) in 

guard image != nil else{ 
     print("Image not exist!") 
     cell.photoImageView.image = resizeImage(image:#imageLiteral(resourceName: "img_refresh"), newWidth: 125) 
     return 
} 

    print("image here!!!") 

    DispatchQueue.global().async { 
     let data = try? Data(contentsOf: url!) //make sure your image in this url does exist, otherwise unwrap in a if let check/try-catch 

           if data != nil 
           { 
            if let image = UIImage(data: data!) 
            { 
             if !FileManager.default.fileExists(atPath: fileURL.path) { 
              if let jpegData = UIImageJPEGRepresentation(image, 0.001) 
              { 
               do { 
                try jpegData.write(to: fileURL, options: .atomic) 
                print("image save local done!!!") 
               } catch { 
                debug(object: error) 
               } 
              } 
             } else { 
              print("image already esist") 

             } 

             DispatchQueue.main.async { 
              cell.photoImageView.image = resizeImage(image: image, newWidth: 175) 

              self.tableView.reloadRows(at: [indexPath], with: .automatic) 
             } 
            } 
           } 
          } 
        }) 


func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { 

    let uuid = NSUUID().uuidString 
    let imageName:String = chatroomId + "_" + uuid + ".jpg" 
    let documentsPath = NSHomeDirectory().appending("/Documents/\(chatroomId)/") 
    let imagePath = documentsPath.appending(imageName) 
    let imageUrl = URL(fileURLWithPath: imagePath) 
    print("imageUrl is here:\(imageUrl)") 

    photoImage = info[UIImagePickerControllerOriginalImage] as? UIImage 


    if picker.sourceType == .camera { 

     photoImage = info[UIImagePickerControllerOriginalImage] as? UIImage 
     UIImageWriteToSavedPhotosAlbum(photoImage!, nil, nil, nil) 
    } 

    let imageData:Data = UIImageJPEGRepresentation(photoImage!, 0.001)! 
    do { 
     try imageData.write(to: imageUrl,options: .atomic) 
    } catch let error { 
     print(error) 
    } 

    //uploading 
     let objectKey:String = "chatroom/" + imageName 
     server.uploadObjectAsync(imageUrl, objectKey: objectKey) 
     let message = server.url + imageName 
     self.room.send(message: message) 
     self.tableView.scrollToBottom() 
     self.tableView.reloadData() 
     self.dismiss(animated: true, completion: nil) 

} 
+0

は、画像があるかどうかをチェックしてみてくださいサーバーにアップロードされているかどうか。あなたのバックエンドの人にそれを確認するように依頼してください。 –

答えて

0

をアップロードし、あなたのsd_setImage機能に.allowInvalidSSLCertificatesを追加しよう:

cell.photoImageView.sd_setImage(with: url, placeholderImage: nil, options: .allowInvalidSSLCertificates, progress: nil 
         , completed: { (image, error, cacheType, url) in 
関連する問題