You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

datan3rd's avatar
datan3rd
Explorer | Level 3
7 years ago

Upload SQLite Not a Database

I have been able to get the Dropbox SDK working for objective C. The problem I am running into is that when I upload my backup of a SQLite database it is no longer being recognized as a DB. After some searching it seems that the issue may be that upon upload the DB may be in use. Any assistance on how to ensure it is not in use before uploading or kill any processes that may be using it? Additionally I noticed that the code for uploading uses "uploadData" whereas the code for downloading uses "downloadURL" - could that have anyhting to do with it?

  • Greg-DB's avatar
    Greg-DB
    7 years ago

    The example I linked to happens to use uploadData, but you can also pass a 'mode' to uploadUrl. Constructing and passing the mode works the same way for both.

  • datan3rd's avatar
    datan3rd
    Explorer | Level 3

    UPDATE: good news is I was able to find some code that worked in uploading the file and the subsequent download and restore is now working.

    New smaller issue:

    I need to figure out the code to allow overwrite as if the backup already exists then it will fail on upload currently. 

     

       [[client.filesRoutes uploadUrl:@"/backups/Backup.sqlite" inputUrl:databasePath]
         setResponseBlock:^(DBFILESFileMetadata *metadata, DBFILESUploadError *uploadError, DBRequestError *error) {
             if (metadata) {
                 NSLog(@"The upload completed successfully.");
                 NSLog(@"File metadata:");
                 NSLog(@"%@", metadata);
                 [self enableRestore];
             } else if (uploadError) {
                 NSLog(@"Something went wrong with the upload:");
                 NSLog(@"%@", uploadError);
             } else if (error) {
                 NSLog(@"Something went wrong with the API call:");
                 NSLog(@"%@", error);
             }
         }];
    • Greg-DB's avatar
      Greg-DB
      Icon for Dropbox Staff rankDropbox Staff

      I'm glad to hear you already sorted out the original issue.

      To control overwriting, you should use this version of the uploadUrl method, which takes a 'mode' parameter. The 'mode' parameter accepts a DBFILESWriteMode object, which you can set to your desired write mode, such as "Overwrite". There's an example of that here.

      • datan3rd's avatar
        datan3rd
        Explorer | Level 3

        Greg - thanks as always for the reply. This code is where I started from. Using that code (uploadData) the SQLite file was not retaining itself as a DB. Switching to the code I have now with uploadUrl is functioning as expected with the exception of the overwrite issue. I will chose the overwrite issue and possibly just code around it if there is no alternative.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,910 PostsLatest Activity: 4 days ago
333 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!