mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
refactoring (#116)
- refactoring architecture - fix incomplete ssh logs - code editor for scripts in the app - remove Jobs and SSHCommands
This commit is contained in:
45
app/SSH/Storage/Dropbox.php
Normal file
45
app/SSH/Storage/Dropbox.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\SSH\Storage;
|
||||
|
||||
use App\Exceptions\SSHCommandError;
|
||||
use App\SSH\HasScripts;
|
||||
|
||||
class Dropbox extends AbstractStorage
|
||||
{
|
||||
use HasScripts;
|
||||
|
||||
public function upload(string $src, string $dest): array
|
||||
{
|
||||
$upload = $this->server->ssh()->exec(
|
||||
$this->getScript('dropbox/upload.sh', [
|
||||
'src' => $src,
|
||||
'dest' => $dest,
|
||||
'token' => $this->storageProvider->credentials['token'],
|
||||
]),
|
||||
'upload-to-dropbox'
|
||||
);
|
||||
|
||||
$data = json_decode($upload, true);
|
||||
|
||||
if (isset($data['error'])) {
|
||||
throw new SSHCommandError('Failed to upload to Dropbox '.$data['error']);
|
||||
}
|
||||
|
||||
return [
|
||||
'size' => $data['size'] ?? null,
|
||||
];
|
||||
}
|
||||
|
||||
public function download(string $src, string $dest): void
|
||||
{
|
||||
$this->server->ssh()->exec(
|
||||
$this->getScript('dropbox/download.sh', [
|
||||
'src' => $src,
|
||||
'dest' => $dest,
|
||||
'token' => $this->storageProvider->credentials['token'],
|
||||
]),
|
||||
'download-from-dropbox'
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user