I am POSTing data to a server (images and string data). I have an attribute in core data called “status” for each object I want to upload. I input 3 statuses into this attribute to indicate the upload status: upload pending (not attempted to upload yet, or previous attempt failed), upload processing (currently uploading), and upload complete (finished uploading, success). I have a timer that checks the DB to upload all pending data.
Is this the proper way to handle uploading of failed data and offline data?
If this is the right way, I am having a problem with changing the status of an upload from “upload processing” to “upload pending” or “upload complete” when the upload is attempting but the user exits the app or when the request times out. Does anyone know how to handle these situations?
By the way, I am using ASIHTTPRequest as the framework to make requests to the server.
A detailed description of how to do this the best way will garner a bounty 🙂
Thanks!
The timer idea will work. Call the uploadOutstandingObjects of your data manager class via a timer at some interval which is appropriate for your application
Say you have an ‘Foo’ entity that needs to be uploaded. You can perform the following in your data manager class…
One way to go about doing this would be to use notifications. Whenever you start an upload, you make that object listen to an “uploadsStopped” notification. When the upload completes, the object being uploaded will stop listening.
Foo Class:
If your app exits you can handle changing the status of the ‘upload processing’ objects which have not yet completed