cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Upload SQLite Not a Database

Upload SQLite Not a Database

datan3rd
Explorer | Level 3

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?

1 Accepted Solution

Accepted Solutions

Re: Upload SQLite Not a Database

Greg-DB
Dropboxer

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.

View solution in original post

4 Replies 4

Re: Upload SQLite Not a Database

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);
         }
     }];

Re: Upload SQLite Not a Database

Greg-DB
Dropboxer

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.

Re: Upload SQLite Not a Database

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.

Re: Upload SQLite Not a Database

Greg-DB
Dropboxer

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.

View solution in original post

Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    datan3rd Explorer | Level 3
What do Dropbox user levels mean?
Need more support?