AFNetworking will not allow downloading large files

With AFNetworking I am trying to download an image (1280x990) with a size: 33695. The code below works fine with smaller images (that is: 390x390), but a larger image causes an error:

[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) { }]; 

ERROR thrown:

 NSDebugDescription = "JSON text did not start with array or object and option to allow fragments not set."; 

I searched for a lot of other posts, and it seems nothing is said about the problems with the large image size. Any suggestions?

+6
source share
2 answers

Based on the author of AFNetworking, PLZ use appendPartWithFileURL instead. Because the data will be stream from disk.

+1
source

I had similar problems when I tried to use AFNetworking. Since then, I switched to using RestKit and SDWebImage to handle asynchronous loading and image caching ... and it works like a charm. You can take a look at this recent Quora entry to better compare the differences between them ... Basically, one con for Restkit was asynchronous and caching, but with a little effort SDWebImage will take care of this with a single line of code.

http://www.quora.com/iOS-Development/RestKit-vs-AFNetworking-What-are-the-pros-and-cons

0
source

Source: https://habr.com/ru/post/956005/


All Articles