@@ 529-546 (lines=18) @@ | ||
526 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-delete |
|
527 | * |
|
528 | */ |
|
529 | public function delete($path) |
|
530 | { |
|
531 | //Path cannot be null |
|
532 | if (is_null($path)) { |
|
533 | throw new DropboxClientException("Path cannot be null."); |
|
534 | } |
|
535 | ||
536 | //Delete |
|
537 | $response = $this->postToAPI('/files/delete_v2', ['path' => $path]); |
|
538 | $body = $response->getDecodedBody(); |
|
539 | ||
540 | //Response doesn't have Metadata |
|
541 | if (!isset($body['metadata']) || !is_array($body['metadata'])) { |
|
542 | throw new DropboxClientException("Invalid Response."); |
|
543 | } |
|
544 | ||
545 | return new DeletedMetadata($body['metadata']); |
|
546 | } |
|
547 | ||
548 | /** |
|
549 | * Move a file or folder to a different location |
|
@@ 731-748 (lines=18) @@ | ||
728 | * @link https://www.dropbox.com/developers/documentation/http/documentation#files-save_url |
|
729 | * |
|
730 | */ |
|
731 | public function saveUrl($path, $url) |
|
732 | { |
|
733 | //Path and URL cannot be null |
|
734 | if (is_null($path) || is_null($url)) { |
|
735 | throw new DropboxClientException("Path and URL cannot be null."); |
|
736 | } |
|
737 | ||
738 | //Save URL |
|
739 | $response = $this->postToAPI('/files/save_url', ['path' => $path, 'url' => $url]); |
|
740 | $body = $response->getDecodedBody(); |
|
741 | ||
742 | if (!isset($body['async_job_id'])) { |
|
743 | throw new DropboxClientException("Could not retrieve Async Job ID."); |
|
744 | } |
|
745 | ||
746 | //Return the Async Job ID |
|
747 | return $body['async_job_id']; |
|
748 | } |
|
749 | ||
750 | /** |
|
751 | * Save a specified URL into a file in user's Dropbox |