Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6960135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:21:48+00:00 2026-05-27T15:21:48+00:00

I am POSTing data to a server (images and string data). I have an

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:21:48+00:00Added an answer on May 27, 2026 at 3:21 pm

    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…

    - (void)uploadOutstandingObjects {
         // I use the great MagicalRecord class for Core Data fetching
         // https://github.com/magicalpanda/MagicalRecord
         NSPredicate *predicate = [NSPredicate predicateWithFormat:@"status == pending"]
         NSArray *outstandingObjects = [Foo MR_findAllWithPredicate:predicate];
         for (Foo *foo in outstandingObjects) {
              [foo uploadToServer];
         }
    

    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:

    - (void)uploadFailed {
        // change status to upload pending in the database for this 'foo' object
    }
    - (void)uploadComplete {
        // change status to upload complete in the database for this 'foo' object
    }
    -(void)uploadToServer {
       [[NSNotificationCenter defaultCenter] addObserver:self
                                                selector:@selector(uploadFailed:)
                                                    name:@"uploadsStoppedNotification"
                                                  object:nil ];
    
       // perform upload. If you are doing this synchronously...
       ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:<url here>];
       [request startSynchronously];
       if (![request error]) {
           [self uploadSucceeded];
           // stop listening to global upload notifications as upload attempt is over
           [NSNotificationCenter removeObserver:self];
       }
       else {
           [self uploadFailed];
           // stop listening to global upload notifications as upload attempt is over
           [NSNotificationCenter removeObserver:self];
    }
    

    If your app exits you can handle changing the status of the ‘upload processing’ objects which have not yet completed

    - (void)applicationDidEnterBackground:(UIApplication *)application {
         // this will fire to any objects which are listening to
         // the "uploadsStoppedNotification"
         [[NSNotificationCenter defaultCenter]
               postNotificationName:@"uploadsStoppedNotification"
                             object:nil ]; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem POSTing data via HTTPS in Java. The server response is
I have an application in which I am posting data to my server API
I have a problem with posting of binary data to server via HttpWebRequest .
I'm posting data to a page called process.aspx that handles some business logic with
A form I don't have any control over is POSTing data to my PHP
I am posting some data using ajax. I want to manipulate that data and
I am posting JSON data to an ASP.NET MVC2 server. I am posting large
I am POSTING some data from an IPhone application want want to be able
I'm POSTing data to a server and successfully execute BeginGetRequestStream, then EndGetRequestStream, write my
I am looking forward for posting some data and information on the web server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.