I need to upload an image to my ASP.Net website, i have got it to work with NSURLConnection but when i needed to upload extremely big files, it crashes due to the lack of ram to transfer the file to NSData then upload it. So I found out about the new API NSURLSession and the method uploadTaskWithRequest:withFile to allow bigger files to be transferred. I have changed the max file limit on the ASP.NET server to allow huge files, and tested it and it works with large files (100MB+), but at some point the phone does not have enough ram to allocate the NSData of the file, when I use NSURLConnection. I have tried NSURLSession numerous times with no success.
Heres an example of what i've tried:
NSString *urlString = [NSString stringWithFormat:@"https://examplesecuresite.com/Index.aspx?username=%@", username];
NSMutableURLRequest *request =
[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"PUT"];
// 3
NSData *noteContents = UIImageJPEGRepresentation(image, 1);
// 4
NSURLSession *session = [[NSURLSession alloc] init];
NSURLSessionUploadTask *uploadTask = [session
uploadTaskWithRequest:request
fromData:noteContents];
[uploadTask resume];