mirror of
https://github.com/Chouchen/Shikiryu_Backup.git
synced 2021-06-30 16:02:14 +02:00
💚 Fix with PHPCS
This commit is contained in:
51
app/code/transport/Dropbox.php
Normal file
51
app/code/transport/Dropbox.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Shikiryu\Backup\Transport;
|
||||
|
||||
use Spatie\Dropbox\Client;
|
||||
|
||||
class Dropbox extends TransportAbstract
|
||||
{
|
||||
/**
|
||||
* Dropbox Client
|
||||
*
|
||||
* @var Client
|
||||
*/
|
||||
private $dropbox;
|
||||
|
||||
protected $token = '';
|
||||
// protected $app = '';
|
||||
protected $folder = '';
|
||||
|
||||
public function __construct($backup, $config)
|
||||
{
|
||||
parent::__construct($backup, $config);
|
||||
$this->dropbox = new Client($this->token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
$sent = true;
|
||||
$files = $this->backup->getFilesToBackup();
|
||||
foreach ($files as $file => $name) {
|
||||
$file = fopen($file, 'rb');
|
||||
$upload = $this->dropbox->upload($this->folder.'/'.$name, $file);
|
||||
if (!$upload) {
|
||||
$sent = false;
|
||||
echo 'DROPBOX upload manqu<71>e de '.$file.' vers '.$this->folder.$name;
|
||||
}
|
||||
}
|
||||
$streams = $this->backup->getStreamsToBackup();
|
||||
foreach ($streams as $stream => $name) {
|
||||
$upload = $this->dropbox->upload($this->folder . '/' . $name, $stream);
|
||||
if (!$upload) {
|
||||
$sent = false;
|
||||
echo 'DROPBOX upload manquée de ' . $file . ' vers '.$this->folder.$name;
|
||||
}
|
||||
}
|
||||
return $sent;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user