|
@@ 1183-1204 (lines=22) @@
|
| 1180 |
|
* @link https://www.dropbox.com/developers/documentation/http/documentation#files-download |
| 1181 |
|
* |
| 1182 |
|
*/ |
| 1183 |
|
public function download($path, $dropboxFile = null) |
| 1184 |
|
{ |
| 1185 |
|
//Path cannot be null |
| 1186 |
|
if (is_null($path)) { |
| 1187 |
|
throw new DropboxClientException("Path cannot be null."); |
| 1188 |
|
} |
| 1189 |
|
|
| 1190 |
|
//Make Dropbox File if target is specified |
| 1191 |
|
$dropboxFile = $dropboxFile ? $this->makeDropboxFile($dropboxFile, null, null, DropboxFile::MODE_WRITE) : null; |
| 1192 |
|
|
| 1193 |
|
//Download File |
| 1194 |
|
$response = $this->postToContent('/files/download', ['path' => $path], null, $dropboxFile); |
| 1195 |
|
|
| 1196 |
|
//Get file metadata from response headers |
| 1197 |
|
$metadata = $this->getMetadataFromResponseHeaders($response); |
| 1198 |
|
|
| 1199 |
|
//File Contents |
| 1200 |
|
$contents = $dropboxFile ? $this->makeDropboxFile($dropboxFile) : $response->getBody(); |
| 1201 |
|
|
| 1202 |
|
//Make and return a File model |
| 1203 |
|
return new File($metadata, $contents); |
| 1204 |
|
} |
| 1205 |
|
|
| 1206 |
|
/** |
| 1207 |
|
* Download a folder as a zip file |
|
@@ 1219-1240 (lines=22) @@
|
| 1216 |
|
* @link https://www.dropbox.com/developers/documentation/http/documentation#files-download_zip |
| 1217 |
|
* |
| 1218 |
|
*/ |
| 1219 |
|
public function downloadZip($path, $dropboxFile = null) |
| 1220 |
|
{ |
| 1221 |
|
//Path cannot be null |
| 1222 |
|
if (is_null($path)) { |
| 1223 |
|
throw new DropboxClientException("Path cannot be null."); |
| 1224 |
|
} |
| 1225 |
|
|
| 1226 |
|
//Make Dropbox File if target is specified |
| 1227 |
|
$dropboxFile = $dropboxFile ? $this->makeDropboxFile($dropboxFile, null, null, DropboxFile::MODE_WRITE) : null; |
| 1228 |
|
|
| 1229 |
|
//Download File |
| 1230 |
|
$response = $this->postToContent('/files/download_zip', ['path' => $path], null, $dropboxFile); |
| 1231 |
|
|
| 1232 |
|
//Get file metadata from response headers |
| 1233 |
|
$metadata = $this->getMetadataFromResponseHeaders($response); |
| 1234 |
|
|
| 1235 |
|
//File Contents |
| 1236 |
|
$contents = $dropboxFile ? $this->makeDropboxFile($dropboxFile) : $response->getBody(); |
| 1237 |
|
|
| 1238 |
|
//Make and return a File model |
| 1239 |
|
return new File($metadata, $contents); |
| 1240 |
|
} |
| 1241 |
|
|
| 1242 |
|
/** |
| 1243 |
|
* Get Current Account |