Skip to content

Commit

Permalink
Ver.5 Redefine the download and downloadZip methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
msyk committed Jul 12, 2022
1 parent 692c457 commit 52424ef
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "msyk/dropbox-api-shortlivedtoken",
"version": "4",
"version": "5",
"time": "2022-07-08",
"repositories": [
{
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions src/DropboxClientModified.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,52 @@ public function authRequest(string $uri, array $parameters = null): array
}
return json_decode($response->getBody(), true) ?? [];
}

/*
* download and downloadZip methods weren't work fine because StreamWrapper::getResource() returns null
* in spite of the $response->getBody() respond something. So the return process of both method changed
* as like. These returns the contents of file itself. 2022-7-12 msyk (nii@msyk.net)
*/
/**
* Download a file from a user's Dropbox.
*
* @param string $path
*
* @return string
*
* @link https://www.dropbox.com/developers/documentation/http/documentation#files-download
*/
public function download(string $path)
{
$arguments = [
'path' => $this->normalizePath($path),
];

$response = $this->contentEndpointRequest('files/download', $arguments);

return $response->getBody()->getContents();
}

/**
* Download a folder from the user's Dropbox, as a zip file.
* The folder must be less than 20 GB in size and have fewer than 10,000 total files.
* The input cannot be a single file. Any single file must be less than 4GB in size.
*
* @param string $path
*
* @return string
*
* @link https://www.dropbox.com/developers/documentation/http/documentation#files-download_zip
*/
public function downloadZip(string $path)
{
$arguments = [
'path' => $this->normalizePath($path),
];

$response = $this->contentEndpointRequest('files/download_zip', $arguments);

return $response->getBody()->getContents();
}

}

0 comments on commit 52424ef

Please sign in to comment.