AFNetworking不允许大文件上传

Sil*_*tar 6 objective-c afnetworking-2

使用AFNetworking我正在尝试上传大小为33695的图像(1280x990).下面的代码与较小的图像(即:390x390)完美配合,但较大的图像会引发错误:

[client POST:@"/upload_image" parameters:nil constructingBodyWithBlock:^(id <AFMultipartFormData>formData) {

    [formData appendPartWithFileData:imageData name:@"image" fileName:@"image.jpg" mimeType:@"image/jpeg"];

} success:^(NSURLSessionDataTask * task, id responderData) {

} failure:^(NSURLSessionDataTask * task, NSError * error) {

}];
Run Code Online (Sandbox Code Playgroud)

抛出的错误:

NSDebugDescription = "JSON text did not start with array or object and option to allow fragments not set.";
Run Code Online (Sandbox Code Playgroud)

我搜索过很多其他帖子,但似乎没有任何内容涉及图像尺寸较大的问题.有什么建议?

Tro*_*inh 1

根据AFNetworking的作者,请改用appendPartWithFileURL。因为数据将从磁盘流式传输。