IOS文件上传遇到流错误

标签 ios file-upload parse-platform

我使用 Parse 作为后端并创建了一个用于上传图片的 IOS 应用。

我用WIFI网络上传没有问题,但是用4g/3g网络上传文件时遇到文件错误。

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

虽然我在代码中发现了错误,但警报 View 没有出现,它只在日志中显示“上传失败”。

    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,上传失败则显示未知字符串。

最佳答案

可能是你的网络问题,你能保证你的网络速度没问题吗?不管你使用什么样的网络,应该没有任何问题,除非它很慢并且导致函数超时。

在上传功能之前,我可以看看你写的处理文件的代码吗?

关于IOS文件上传遇到流错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22216611/

相关文章:

ios - 解析不会保存安装,错误 : badge must be a non-negative integer

javascript - 从 Parse.com 中的另一个类设置查询降序

c++ - 下载自定义文件格式

ios - 从 ViewController 中的 AppDelegate 访问数据。

ios - 通用链接在 iOS 13 上没有重定向

ios - Swift 可选值及其实例化

iphone - 编辑模式后 UITableViewCell 刷新问题

ios - 基于窗口的应用程序和基于 View 的应用程序有什么区别?

java - 将文件从 JSP 发送到调用接口(interface)方法的 Controller - 如何从该请求上传文件?

ruby-on-rails - Ruby on Rail、Carrierwave - 表单验证失败时文件上传字段消失