I have a problem with http PUT request and request body as stream from file.
No matter what the size of the file i get error \"NSURLErrorDomain -1021 request body st
I was encountering this same problem, what fixed it for me was retaining the stream then releasing it at the end of the asynchronous HTTP transaction. Doesn't seem like this should be necessary, however it got me around the problem.
From the looks of it, it seems that you're not setting @"Content-Length" in the header.
The way I do it is like this:
NSUInteger fileSize = [[[[NSFileManager defaultManager] attributesOfItemAtPath:_dataStreamLocation error:nil] objectForKey:NSFileSize] unsignedIntegerValue];
[request setValue:[NSString stringWithFormat:@"%u", fileSize] forHTTPHeaderField:@"Content-Length"];
Either way, I was doing batch uploading and occasionally got the body stream exhaustion error. From what I could tell, the issue was that I only had few free space on the device, and the temporary files would get deleted automatically before some uploads being finished (when receiving the error I tested to check if the file was still there, and it wasn't).