iPhone. How to Track Progress of HTTP Upload - iphone

could you please advice how to track progress of file upload to HTTP Server?
I am using NSURLConnection and other classes to solve the task of file upload.
But I cann't find out how to track upload progress.
Thanks.

I asked something similar awhile back:
CFNetwork HTTP timeout?
I don't know if ASIHTTPRequest has this support built-in yet, and I didn't have a reason back then to switch over, but you may want to check it out and/or contact the authors.

Related

Is there a reliable alternative to NSURLConnection?

My app is calling a web service to retrieve some data, and I want to make the experience as best as possible. I figured out that using NSURLConnection it's very hard to give good timely feedback.
Sometimes my iPhone tries to load the data for a minute or two and I see no way of figuring out what is taking so long, or why the download is so troublesome. Then after a few minutes I sometimes end up with an error code.
I'd like to display exactly what is happening. Messages like:
"Establishing internet connection"
"Trying to connect to server"
"Connected..."
"Downloading data..."
"Download complete!"
And when there is trouble like server not reachable or DNS could not be resolved, it would be nice to just try again a few times and not simply quit and throw error.
Are there replacements for NSURLConnection which handle these things more gracefully and give better in-time feedback about what is happening?
I've been a big fan of the AFNetworking library. Very easy to use and wraps all your networking calls in blocks that are very easy to work with.
It is also is kept very current, so you should be safe in getting all the updates it needs as your project progresses and ages.
I think you should be misusing NSURLConnection and NSURLConnectionDelegate, since you can do most of you needs with them.
But, what about MKNetworkKit? I've been using it and it really makes those kind of issues easier to deal with.
Something that can help you achieve what you want. Since ASIHTTPRequest is no longer being supported MKNetworkKit would be your best choice. To check for connectivity, you can always use Reachability.

how to handle non responsive UI while downloading from NSURL

after looking at this question, I do not know how to handle non responsive UI while writing a large pdf file (on 3G connection let's say) from a remote server to the documents directory, is there way to solve this issue ?
Either use Blocks and Grand Central Dispatch,an NSOperation or an asynchronous NSURLConnection request
All are well explained in the Apple docs.
You can perform the download on a background thread using performSelectorInBackground.

Video recording and saving the video on a server

I just caught with a task which is how should i go about capturing a video in my app and saving it directly on some server. I have the sample code discussed in WWDC2010 but i just need some other more helpful links or tutorials to complete this task.
Please give me your opinion or share any links if you have.
Thanks,
There is nothing in the APIs that will allow you to do this. The only way is to use AVAssetWriters to segment the video. You would then stream the completed segments. These would need to be reassembled on the server side if you require a single file.

iPhone: Load Queue on Startup

I've not found a answer to this question anywhere, but this seems like a typical problem:
I would like to send some POST-Requests (with ASIHTTPRequest, what I already do), but if something goes wrong, ther user can decide to "Try Later", that means, the task should be put on a queue and this queue should be read next time the application starts. So, that's my question: how to "save" the queue, so that the app can read it next time it starts? Is it possible to "read" the queue and try sending this POST-Request again, let's say, 10 min later, even if the application is not running?
What kind of documentation should I read in order to be able to do this?
I would be very glad to hear any answers. Thanks in advance.
P.S.: Another Idea I have: as I just have to Upload Photos, I could have a folder with all the Photos that still need to be uploaded, and when the App starts, the app looks at this folder and try to send all the photos in this folder. Does it make sense?
My approach for this issue would be like this:
Whenever you fail to send details - write content of the array to a file using '[NSArray writeToFile:]' you can use serialization if array contain any data which is custom defined (if your array contain standard cocoa objects(NSString,NSData etc) they already implemented with serialization )
When app launches; load the content from file directly to an array object ('[NSArray arrayWithContentsOfFile:]')
then construct http request and try sending. In application the data(in your case array) is stored/serialized not the request, you need to reconstruct the http request when you want to try one more time.(don't try serializing ASIHTTPRequest, you have reconstruct it)
I'm going to assume you've already looked at NSOperationQueue and NSOperation. AFAIK there is no built-in support for serializing NSOperation, but you could very easily write your own serialization mechanism for an NSOperation subclass that you use for posting data and write the an NSOperationQueue's operations to disk if something goes wrong.
Without knowing too many details it's hard to give a precise answer. There are many ways to write data to disk and load it again later, the direction you take will be largely dependent on your situation.

Sending NSdata from device to desktop (mail)?

I have an app holding an array of instances of a class called SwimmingPool.
At present my application persistence is dealt with by encoding everything into NSData and saving that to the iPhone. This is then reloaded everytime the app starts.
I have a few friends populating their individual applications with instances of SwimmingPool. I want them to send me their application information. I will then import it all into my 'master' app, pooling everyones SwimmingPool instances and finally I will submit the app to the appStore.
My question is, What is the best way for me to receive their data? Is it possible for my app to encode to an instance of NSData and then export that to mail on the iphone/ipod touch? (they can email it to me)
I will then create an import method to parse the individual swimming pools into my main NSData.
Is this possible?/the best solution?
Thanks alot everyone who has answered my previous questions. I hope to contribute to this community as much as I can. (not just with questions!)
Dan
I would have the app post the data to a server via HTTP.
Is it an app for Skateboarders to locate empty swimming pools? Great app idea!
You should take a look at the NSURLConnection class, which allows you to post data to a HTTP server, or retrieve data from it.
If you don't need the fancy asynchronous download of the HTTP request results, you can also look at [NSData +dataWithContentsOfURL:] to fetch the results synchronously.