I try to upload a file to DropBox using their API and PHP. Thats the code:
require_once "dropbox/lib/Dropbox/autoload.php";
use \Dropbox as dbx;
$appInfo = dbx\AppInfo::loadFromJsonFile("app_info.json");
$csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
$webAuth = new dbx\WebAuth($appInfo, "NoteBoxApp/0.01", "http://localhost/notes", $csrfTokenStore, null);
$title=$_POST["titulo"].".txt";
$nota=$_POST["conteudo"];
$accessToken=$_SESSION["token"];
$clientIdentifier=$_SESSION["userId"];
$client= new dbx\Client($accessToken, $clientIdentifier);
$file = fopen($title, "w") or die("Unable to open file!");
fwrite($file, $nota);
$stat = fstat($file);
$size = (int) $stat['size'];
$dropboxPath="/Aplicativos/Notes01";
try{
$metadata = $client->uploadFile($dropboxPath, dbx\WriteMode::add(), $file, $size);
}
catch(Exception $e) {
echo "Exceção: ", $e->getMessage(), "\n";
}
fclose($file);
I always get the exception
Error executing HTTP request: Operation too slow. Less than 1024 bytes/sec transferred the last 10 seconds
I cant see why! I using XAMPP on localhost!... Thanks in advance for the help!