2015-11-02 51 views
0

我使用WWW(不是WWWForm)將圖像文件上傳到服務器。
當我在iOS 9或更低版本上運行時可以,但是當我在iOS 9.1上測試時,WWW會返回「超時」錯誤。
任何人都知道這個錯誤:((iOS 9.1上的Unity WWW超時錯誤

string server_ip = url; 
byte[] file_byte_array = array_of_file; 
var post_header = new Dictionary<string, string>(); 
WWW stream = new WWW(server_ip, file_byte_array, post_header); 

yield return www; 

if(www.error != null) 
{ 
    Debug.LogError("ERROR : " + www.error); 
} 
+0

歡迎StackOverflow的!請有讀[如何提出一個很好的問題] (http://stackoverflow.com/help/how-to-ask)!電話我們已經嘗試過了,並提供了所有必要的細節。 –

+0

它是否通過HTTP?你是否禁用了應用程序傳輸安全檢查 – peterept

+0

@peterept是啊,它是通過HTTP,但是當我**下載**一個圖像時,沒關係。我**上傳**圖像時返回錯誤:(( –

回答

0

好吧,我不能使用WWW上傳,所以我嘗試了C#的Socket

  request.Method = "POST"; 
      request.ContentType = "text/plain"; 

      byte[] fileToSend = arrByteAva; 
      request.ContentLength = fileToSend.Length; 

      using (Stream requestStream = request.GetRequestStream()) 
      { 
       // Send the file as body request. 
       requestStream.Write(fileToSend, 0, fileToSend.Length); 
       requestStream.Close(); 
      } 
0

我想這是因爲Xcode中7.您的info.plist添加這個AppTransport安全:NSAppTransportSecurity型詞典和這裏面添加具有布爾類型NSAllowArbitraryLoads並將其設置爲YES