I need to send large amounts of data (image files) by POST in a WebView
, so I'm using NSMutableURLRequest
with setHTTPBody:
.
Problem: if the data size is more than about 3MB, the app suddenly starts eating up huge amounts of memory and gets dog slow with all the paging.
I've tried changing this:
[request setHTTPBody:[NSData dataWithBytes:post.Get() length:post.Size()]];
..to this:
[request setHTTPBodyStream:[NSInputStream inputStreamWithData:
[NSData dataWithBytes:post.Get() length:post.Size()]]];
..but then nothing seems to happen and the request just times out. I get none of the normal callbacks (like WebViewProgressEstimateChangedNotification
) and the data doesn't seem to get set.
So, how do I (a) make the NSData
approach not be a memory hog or (b) make the stream approach work (assuming it's a good workaround)?