cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more 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: 

Re: Code for APIv2

Code for APIv2

jiska78
Explorer | Level 3
Go to solution

Sorry, I'm just a hack trying to upload a database backup to dropbox. API v1 worked fine but now I'm forced to migrate.

 

Here's the code I used to use, with the old API v1 commands and the new API v2 ones.

 

Not working - can someone please help?

 

use Dropbox\Dropbox;
use Dropbox\DropboxApp;
use Dropbox\DropboxFile;
$app = new DropboxApp(1,2,3);
$dropbox = new Dropbox($app);
$backupFile = "/home/edplorga/backups/temp/db_" . date('d-m-Y').".zip";
$backupFilename = "/db_" . date('d-m-Y').".zip";
 
//Old stuff
$appInfo = dbx\AppInfo::loadFromJsonFile(DIR."/config.json");
$dbxClient = new dbx\Client($accessToken, "EDPL_SQL_Backups");
$f = fopen($backupFile, "rb");
$result = $dbxClient->uploadFile($backupFilename, dbx\WriteMode::force(), $f);
fclose($f);
 
//New stuff
$dropboxFile = DropboxFile::createByStream($backupFilename, $backupFile);

 

11 Replies 11

yunu
New member | Level 2
Go to solution

how to write code for File Upload using Nodejs

 

Здравко
Legendary | Level 20
Go to solution

Hi @yunu,

Take a look on the example here.

Hope this helps.

Need more support?