I have to implement a file upload for my app. Files like Assets (which can be Photo or Video) should be uploaded to a web sever using a REST interface.
The upload would use a form data request with custom header attributes.
Problem:
Holding large files like Videos in an NSData
object can lead to memory issues. This would be the standard approach.
Solution
Providing an NSInputStream
for the body part of the request - and write data piece by piece to the HTTP Body Stream.
Question Can anyone provide an exmaple of how to use an NSInputStream in combination with a NSURLrequest
and NSURLConnection
?
I wrapped my head around several incomplete examples -
but I do not know how to deal with the following method
- (NSInputStream *)connection:(NSURLConnection *)connection needNewBodyStream:(NSURLRequest *)request
I don't want to use any third party library.