| @@ 19-54 (lines=36) @@ | ||
| 16 | * @link http://phpbu.de/ |
|
| 17 | * @since Class available since Release 5.1.0 |
|
| 18 | */ |
|
| 19 | class Dropbox extends Remote |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * @var DropboxApi |
|
| 23 | */ |
|
| 24 | protected $client; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * Dropbox constructor. |
|
| 28 | * |
|
| 29 | * @param DropboxApi $client |
|
| 30 | * @param FileMetadata $dropboxFile |
|
| 31 | */ |
|
| 32 | public function __construct(DropboxApi $client, FileMetadata $dropboxFile) |
|
| 33 | { |
|
| 34 | $this->client = $client; |
|
| 35 | $this->filename = $dropboxFile->getName(); |
|
| 36 | $this->pathname = $dropboxFile->getPathDisplay(); |
|
| 37 | $this->size = $dropboxFile->getSize(); |
|
| 38 | $this->lastModified = strtotime($dropboxFile->getClientModified()); |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * Deletes the file. |
|
| 43 | * |
|
| 44 | * @throws \phpbu\App\Exception |
|
| 45 | */ |
|
| 46 | public function unlink() |
|
| 47 | { |
|
| 48 | try { |
|
| 49 | $this->client->delete($this->pathname); |
|
| 50 | } catch (\Exception $e) { |
|
| 51 | throw new \phpbu\App\Exception($e->getMessage()); |
|
| 52 | } |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| @@ 19-64 (lines=46) @@ | ||
| 16 | * @link http://phpbu.de/ |
|
| 17 | * @since Class available since Release 5.1.0 |
|
| 18 | */ |
|
| 19 | class GoogleDrive extends Remote |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * Google drive api service. |
|
| 23 | * |
|
| 24 | * @var \Google_Service_Drive |
|
| 25 | */ |
|
| 26 | private $service; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * Goole api file id. |
|
| 30 | * |
|
| 31 | * @var string |
|
| 32 | */ |
|
| 33 | private $fileId; |
|
| 34 | ||
| 35 | /** |
|
| 36 | * Constructor. |
|
| 37 | * |
|
| 38 | * @param \Google_Service_Drive $service |
|
| 39 | * @param \Google_Service_Drive_DriveFile $googleFile |
|
| 40 | */ |
|
| 41 | public function __construct(Google_Service_Drive $service, Google_Service_Drive_DriveFile $googleFile) |
|
| 42 | { |
|
| 43 | $this->service = $service; |
|
| 44 | $this->filename = $googleFile->getName(); |
|
| 45 | $this->pathname = $googleFile->getId(); |
|
| 46 | $this->fileId = $googleFile->getId(); |
|
| 47 | $this->size = $googleFile->getSize(); |
|
| 48 | $this->lastModified = strtotime($googleFile->getCreatedTime()); |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * Deletes the file. |
|
| 53 | * |
|
| 54 | * @throws \phpbu\App\Exception |
|
| 55 | */ |
|
| 56 | public function unlink() |
|
| 57 | { |
|
| 58 | try { |
|
| 59 | $this->service->files->delete($this->fileId); |
|
| 60 | } catch (\Exception $e) { |
|
| 61 | throw new Exception($e->getMessage()); |
|
| 62 | } |
|
| 63 | } |
|
| 64 | } |
|
| 65 | ||