2014-03-06 49 views
1

我使用Parse作爲後端,並創建一個iOS應用上傳圖像。IOS文件上傳遇到流錯誤

使用WIFI網絡上傳時沒有問題,但使用4g/3g網絡時遇到文件上傳錯誤。

Encountered stream error: Error Domain=NSPOSIXErrorDomain Code=54 "The operation couldn’t be completed. Connection reset by peer" 

雖然我在代碼中發現了錯誤,但警報視圖沒有顯示,但它僅在日誌中顯示「上傳失敗」。

PFFile *file = [PFFile fileWithName:fileName data:fileData]; 
[file saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { 
    if (error) { 
     UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"An error occured!" message:@"Please try submiting your item again." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; 
     [alertView show]; 
    } 

在後端的數據是這樣的: enter image description here

正如你所看到的,成功上傳的文件名是image.jpg的,不成功的,它顯示了不明字符串。

回答

-1

它可能是你的網絡問題,你能確保你的網絡的速度是好的嗎?不管使用什麼類型的網絡,都不應該有任何問題,除非它很慢並且會導致該功能超時。

在上傳功能之前,我可以看到您編寫的用於處理文件的代碼嗎?