Request for streaming multi-processor iOS HTTP application

I need to implement file upload for my application. Files, such as Assets (which can be photos or videos), must be uploaded to the web server using the REST interface.

The download will use a form data request with custom header attributes.

Problem: Holding large files, such as video in an NSData object, can lead to memory problems. This will be a standard approach.

Solution Providing NSInputStream for the main part of the request - and writing the data in parts to the HTTP stream stream.

Question Can someone provide an example of using NSInputStream in combination with NSURLrequest and NSURLConnection ?

I wrapped my head around a few incomplete examples -

but i don't know how to handle the following method

 - (NSInputStream *)connection:(NSURLConnection *)connection needNewBodyStream:(NSURLRequest *)request 

I do not want to use a third-party library.

+6
source share
1 answer

I know that you do not want to use a third-party library, but can you use them as a reference to see how to perform such tasks?

Perhaps you can take a look at AFNetworking to find out how Matt achieved these kinds of things.

I also suggest using Sessions, which are more documented and reliable (if the target platform makes them available)

0
source

Source: https://habr.com/ru/post/956161/


All Articles