Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AFNetworking won't allow large file upload

With AFNetworking I'm trying to upload an image (1280x990) with size: 33695. The code below works perfectly with smaller images (ie:390x390) but the larger image throws 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've searched many other posts and there doesn't seem to be anything referring to issues with a larger image size. Any suggestions?

like image 233
Silverstar Avatar asked Oct 15 '13 18:10

Silverstar


1 Answers

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

like image 160
Trong Dinh Avatar answered Oct 20 '22 02:10

Trong Dinh