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

  • Home
  • SEARCH
  • 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 8972557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:14:41+00:00 2026-06-15T18:14:41+00:00

I have an iOS app that uses Core Data for persistent data storage. I

  • 0

I have an iOS app that uses Core Data for persistent data storage. I integrated Dropbox as a way for users to perform a a backup of the persistent store file (appname.sqlite).

A UIButton calls a method to see if a file already exists on Dropbox:

            if([[DBSession sharedSession]isLinked])
            {
               NSString *folderName = [[self.dateFormatter stringFromDate:[NSDate date]] stringByReplacingOccurrencesOfString:@"/" withString:@"-"];
               NSString *destinationPath = [NSString stringWithFormat:@"/GradeBook Pro/Backup/%@/",folderName];
               self.metadataIndex = METADATA_REQUEST_BACKUP;
               [self.restClient loadMetadata:destinationPath];
            }

The loadedMetadata delegate method initiates the upload with the rev number of the existing file (if one exists).

-(void) restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata
{
            SAVE_CORE_DATA;
            NSString *folderName = [[self.dateFormatter stringFromDate:[NSDate date]] stringByReplacingOccurrencesOfString:@"/" withString:@"-"];
            NSString *documentsDirectory = DOCUMENTS_DIRECTORY;
            NSString *sourcePath = [NSString stringWithFormat:@"%@/GradeBookPro.sqlite", documentsDirectory];
            NSString *destinationPath = [NSString stringWithFormat:@"/GradeBook Pro/Backup/%@/",folderName];
            [self.restClient uploadFile:@"GradeBookPro.sqlite" toPath:destinationPath withParentRev:[[metadata.contents lastObject]rev] fromPath:sourcePath];               
}

This works well for reasonably small files or large files over a perfect network connection but any small error during the upload cancels the whole process. I would like to switch to using the chunked upload methods but I’m at a loss as to how to actually do the ‘chunking’ of the .sqlite file.

I can’t seem to find any sample apps that are using the chunked upload that I can learn from and the documentation simply says to provide the file in chunks.

So, my questions are:

  1. Is the chunked upload the right approach to addressing the user issues with uploading large files over a possibly spotty network connection?

  2. Can you point me to sample code / app / documentation for ‘chunking’ a file? I’m pretty comfortable with the Dropbox SDK.

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-06-15T18:14:42+00:00Added an answer on June 15, 2026 at 6:14 pm

    I’m going to answer this myself just in case anyone else has the same issue.

    It turns out that I was making this way more difficult than it needed to be. The Dropbox SDK handles chunking the files so I just needed to initate the transfer and react to the delegate calls. The methods used are:

    To send a file chunk – for the first chunk, use nil for the uploadId and 0 for the offset:

    - (void)uploadFileChunk:(NSString *)uploadId offset:(unsigned long long)offset fromPath:(NSString *)localPath;
    

    After sending the last chunk, use this method to commit the upload:

    - (void)uploadFile:(NSString *)filename toPath:(NSString *)parentFolder withParentRev:(NSString *)parentRev fromUploadId:(NSString *)uploadId;
    

    I handled the delegate method as follows:

        - (void)restClient:(DBRestClient *)client uploadedFileChunk:(NSString *)uploadId newOffset:(unsigned long long)offset fromFile:(NSString *)localPath expires:(NSDate *)expiresDate
        {
            unsigned long long fileSize = [[[NSFileManager defaultManager]attributesOfItemAtPath:[FileHelper localDatabaseFilePath] error:nil]fileSize];
    
            if (offset >= fileSize)
            {
                //Upload complete, commit the file.
                [self.restClient uploadFile:DATABASE_FILENAME toPath:[FileHelper remoteDatabaseDirectory] withParentRev:self.databaseRemoteRevision fromUploadId:uploadId];
            }
            else
            {
                //Send the next chunk and update the progress HUD.
                self.progressHUD.progress = (float)((float)offset / (float)fileSize);
                [self.restClient uploadFileChunk:uploadId offset:offset fromPath:[FileHelper localDatabaseFilePath]];
            }
        }
    

    Since the main problem that I was trying to address was handling poor connections I implemented delegate method for failed chunk uploads:

    - (void)restClient:(DBRestClient *)client uploadFileChunkFailedWithError:(NSError *)error
    {
        if (error != nil && (self.uploadErrorCount < DROPBOX_MAX_UPLOAD_FAILURES))
        {
            self.uploadErrorCount++;
            NSString* uploadId = [error.userInfo objectForKey:@"upload_id"];
            unsigned long long offset = [[error.userInfo objectForKey:@"offset"]unsignedLongLongValue];
            [self.restClient uploadFileChunk:uploadId offset:offset fromPath:[FileHelper localDatabaseFilePath]];
        }
        else
        {
          //show an error message and cancel the process
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an iOS app that uses a SQLite DB to store its data
I am developing an app that uses Core Data. In iOS 5, I don't
I have an iOS application that uses core data. I've built my NSManagedObjectModel .
I am maintaining an iOS app that currently uses Core Data to get data
I have an iOS app that uses a number of enums for valid values,
I have a iOS app that, in a nutshell, uses a UITableView and a
I have an app that struggles to perform well on iOS 5 running on
I have developed an iOS app that uses CoreData/SQLite. It works, but now I
I have an iOS app that uses sqlite3 databases extensively. I need to add
I have an iOS app that connects to a server periodically looking for data

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.