Hi there
I use the dropbox v2 api to upload a file using laravel and guzzle.
However the file in dropbox shows empty. Those files have a sie of 0 bytes.
It have to do with my post call to the API because the file contents are still there before calling the upload call.
$client = new Client;
$response = $client->post("https://content.dropboxapi.com/2/files/upload", [
'headers' => [
'Authorization' => 'Bearer '.$this->getAccessToken(),
'Dropbox-API-Arg' => json_encode([
'path' => $path,
'mode' => 'add',
'autorename' => true,
'mute' => true,
'strict_conflict' => false
]),
'Content-Type' => 'application/octet-stream',
'data-binary' => "@$file"
]
]);
return json_decode($response->getBody()->getContents(), true);
UPDATE
After some testing I made it work with using
'body' => fopen($file, "r")
instead of
'data-binary' => "@$file"
as described in the dropbox api v2 documentation.
Is there a better solution to this?