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 4617520
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:08:09+00:00 2026-05-22T02:08:09+00:00

I am getting slightly frustrated with the DropBox API. It is supposed to be

  • 0

I am getting slightly frustrated with the DropBox API. It is supposed to be all simple and straight forward, but I have yet to come a across a simple and plain explanation of how to do a simple sync.

I followed all the instruction you can find in the readme which comes withe DropBox API. To test the whole thing, I have created two buttons to download and upload a file from or to my DropBox. The files are found in my app documents folder.

This works splendidly:

    -(void) DBupload:(id)sender
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents directory
    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"MyExample.txt"];
    // NSError *error;
    [self.restClient uploadFile:@"MyExample.txt" toPath:@"/MyExamplePath" fromPath:filePath];
}

-(void) DBdownload:(id)sender
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents directory
    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"MyExample.txt"];
    NSError *error;
    [self.restClient loadFile:@"/myExamplePath/MyExample.txt" intoPath:filePath];
}

However, I am now wondering how to achieve a simply sync. Right now, I can manually upload and download. But what I need in order to sync is to:

  • find out if the MyExample.txt in my App’s folder or in my DropBox folder is more recent
  • if the txt in the App’s folder is more recent: drop it into dropbox (overriding the old), i.e. call my DBupload method
  • if the txt in the drop box is more recent: download it into the apps folder, i.e. call my DBdownload method

Perhaps I am just too dumb, but does dropBox detail somewhere how to achieve this rather simple and straight forward task?

I know that there is this but it doesn’t really give any code samples.

Thanks for any suggestions.


EDIT

OK, so I figured that my first step is to find out the last modified date of MyExample.txt which is found in the dropBox.

I wrote a wonderful method called DBsync in which I simply put this command:

 -(void) DBsync
{
    [self.restClient loadMetadata:@"/myExamplePath"];

}

This calls the following method which gets the metadata. This was a suggested answer to this post, and I commented it a bit out so as to make it plain what is happening (if there are more dumb people like myself:

 - (void)restClient:(DBRestClient*)client loadedMetadata:(DBMetadata*)metadata {

    NSLog(@"restClient:loadedMetadata function called");

    NSEnumerator *e= [metadata.contents objectEnumerator]; // indexes files in dropbox?
    DBMetadata *dbObject;   // loads metadate we need, e.g. lastModifiedDated
    int numberOfFiles = [metadata.contents count]; // counts files in DropBox - I guess we don't really need this
    NSLog(@"numberOfFiles %i", numberOfFiles); 

    while ((dbObject = [e nextObject])) { // this goes through every single file in the DropBox
        if (!dbObject.isDirectory) { // this determines whether we are talking about a file or a folder
            NSString *fileName = [dbObject.path lastPathComponent]; // this puts the name of the last component, e.g. in /MyExamplePath/MyExample.txt = MyExample.txt into fileName
            NSLog(@"File which is currently being checked: %@", fileName);

            if ([fileName isEqualToString:@"MyExample.txt"]) {  

                NSLog(@"Found it: %@", fileName);
                NSLog(@"Date last modified: %@", dbObject.lastModifiedDate); 

                /* to do: call dbupload if dbObject.lastModifiedDate > than your local file*/
            }
        }
    }
}

I will post the next step once I managed to do so…

  • 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-22T02:08:09+00:00Added an answer on May 22, 2026 at 2:08 am

    I think what you are looking for is the loadmetadata method. Here is an untested example:

    - (void)restClient:(DBRestClient*)client loadedMetadata:(DBMetadata*)metadata {
        NSEnumerator *e= [metadata.contents objectEnumerator];
        DBMetadata *dbObject;
        numberOfFiles = [metadata.contents count];
        while ((dbObject = [e nextObject])) {
        if (!dbObject.isDirectory) {
            NSString *fileName = [dbObject.path lastPathComponent];
            if (![fileName isEqualToString:@"MyExample.txt"]) {  
               /* call dbupload if dbObject.lastModifiedDate > than your local file*/
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a loop variable that does not appear to be getting garbage collected
Getting pretty frustrated with this. I installed pygtk 2.24, pycairo 1.8.10, and pyobject 2.28.3
I have started to have a play with Android programming and I got a
I have a service that is always running, it has a timer to perform
Getting a background process ID is easy to do from the prompt by going:
Getting this error while trying to erase the last element of a list. I
getting following error: SMTP -> ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed:
Getting ORA-00918: column ambiguously defined: running this SQL: SELECT * FROM (SELECT DISTINCT(coaches.id), people.*,
Getting the following on any build running on CC.NET V1.6 on a server. I
Possible Duplicate: Android How to draw a smooth line following your finger I'm new

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.