0

Do I need multipart as content_type if I am uploading a simple jpeg image using NSURLSessionUploadTask?

NSData *picture1 = UIImageJPEGRepresentation([self.imagesArray firstObject], 0.5);
NSData *postbody = picture1;
NSURLSessionUploadTask *task = [self.urlSession uploadTaskWithRequest:request fromData:postData      completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
    NSLog(@" response  %@", response);
    NSLog(@" error  %@", error); 
}]; 

thanks

ehassan2014
  • 99
  • 1
  • 5
  • It depends entirely upon your server code, but multipart is far more common. You should share your server code (or talk with the server developer). – Rob Aug 29 '14 at 01:50
  • so yes, it was essential with this server, and I was able to upload 1 image. but not the second. – ehassan2014 Aug 29 '14 at 02:39
  • I don't understand your comment. Does your server require multipart or not? If it does, then it might also support the uploading of a second image in the same request. If it doesn't (i.e. if the image is just the payload), then you undoubtedly would need to upload subsequent files with separate upload tasks. – Rob Aug 29 '14 at 07:05

0 Answers0