diff --git a/sdk/Dropbox.php b/sdk/Dropbox.php index ed2dad3..1b356b4 100644 --- a/sdk/Dropbox.php +++ b/sdk/Dropbox.php @@ -45,6 +45,7 @@ public static function postRequest($endpoint, $headers, $data, $json = TRUE) { curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + $r = curl_exec($ch); curl_close($ch); diff --git a/sdk/Dropbox/Files.php b/sdk/Dropbox/Files.php index ae6b7f2..809bbd6 100644 --- a/sdk/Dropbox/Files.php +++ b/sdk/Dropbox/Files.php @@ -1,7 +1,6 @@ toJson(); $headers = array( - "Content-Type" => 'application/octet-stream', - "Dropbox-API-Arg" => $entry.toJson() + "Content-Type: application/octet-stream", + "Dropbox-API-Arg: $entry" ); - $headers = json_encode($headers); - $postdata = file_get_contents($file_path); $returnData = Dropbox::postRequest($endpoint, $headers, $postdata); if (isset($returnData["error"])) { return $returnData["error_summary"]; @@ -749,17 +759,22 @@ public function finish_batch_check($async_job_id) { } } - /* - * starts an upload session, needed where the size of a file is greater than 150 MB - * can last up to 48 hours - */ - public function upload_session_start($file_path, $close = false) { + /** + * + * @param $postdata (This is a chunked content resource e.g. outputted by fread) + * @param boolean $close + * @return mixed + */ + public function upload_session_start($postdata, $close = false) { $endpoint = "https://content.dropboxapi.com/2/files/upload_session/start"; + $close = 'false'; + if (true === $close) { + $close = 'true'; + } $headers = array( "Content-Type: application/octet-stream", "Dropbox-API-Arg: {\"close\": $close}" ); - $postdata = file_get_contents($file_path); $returnData = Dropbox::postRequest($endpoint, $headers, $postdata); if (isset($returnData["error"])) { return $returnData["error_summary"];