s3 constructor

This commit is contained in:
fogelito
2023-08-08 12:32:24 +03:00
parent cea7ab8d4c
commit d1efcd6a61
3 changed files with 12 additions and 12 deletions
Generated
+4 -4
View File
@@ -2626,12 +2626,12 @@
"source": {
"type": "git",
"url": "https://github.com/utopia-php/storage.git",
"reference": "25f6b80b3063b85d7c9483be85f7b6ffea4c1edd"
"reference": "cef63e2d76156c2069c98ccd1430ebac5df3a35c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/storage/zipball/25f6b80b3063b85d7c9483be85f7b6ffea4c1edd",
"reference": "25f6b80b3063b85d7c9483be85f7b6ffea4c1edd",
"url": "https://api.github.com/repos/utopia-php/storage/zipball/cef63e2d76156c2069c98ccd1430ebac5df3a35c",
"reference": "cef63e2d76156c2069c98ccd1430ebac5df3a35c",
"shasum": ""
},
"require": {
@@ -2673,7 +2673,7 @@
"issues": "https://github.com/utopia-php/storage/issues",
"source": "https://github.com/utopia-php/storage/tree/feat-transfer"
},
"time": "2023-08-08T02:58:34+00:00"
"time": "2023-08-08T08:09:59+00:00"
},
{
"name": "utopia-php/swoole",
+1 -1
View File
@@ -50,7 +50,7 @@ class Backup extends Action
{
$this->database = $database;
$this->dsn = $this->getDsn($database);
$this->s3 = new DOSpaces('/' . $this->database . '/full', App::getEnv('_DO_SPACES_ACCESS_KEY'), App::getEnv('_DO_SPACES_SECRET_KEY'), App::getEnv('_DO_SPACES_BUCKET_NAME'), App::getEnv('_DO_SPACES_REGION'));
$this->s3 = new DOSpaces('/' . $database . '/full', App::getEnv('_DO_SPACES_ACCESS_KEY'), App::getEnv('_DO_SPACES_SECRET_KEY'), App::getEnv('_DO_SPACES_BUCKET_NAME'), App::getEnv('_DO_SPACES_REGION'));
if (is_null($this->dsn)) {
Console::error('No DSN match');
+7 -7
View File
@@ -19,6 +19,7 @@ class Restore extends Action
public const PROCESSORS = 4;
protected ?DSN $dsn = null;
protected string $database;
protected ?DOSpaces $s3 = null;
public function __construct()
{
@@ -42,9 +43,10 @@ class Restore extends Action
{
$this->database = $database;
$this->dsn = $this->getDsn($database);
$this->s3 = new DOSpaces('/' . $database . '/full', App::getEnv('_DO_SPACES_ACCESS_KEY'), App::getEnv('_DO_SPACES_SECRET_KEY'), App::getEnv('_DO_SPACES_BUCKET_NAME'), App::getEnv('_DO_SPACES_REGION'));
if (!$this->dsn instanceof DSN) {
Console::error('No dsn match');
if (is_null($this->dsn)) {
Console::error('No DSN match');
Console::exit();
}
@@ -100,19 +102,17 @@ class Restore extends Action
public function download(string $file, Device $local)
{
$filename = basename($file);
$s3 = new DOSpaces($this->database . '/full', App::getEnv('_DO_SPACES_ACCESS_KEY'), App::getEnv('_DO_SPACES_SECRET_KEY'), App::getEnv('_DO_SPACES_BUCKET_NAME'), App::getEnv('_DO_SPACES_REGION'));
try {
$path = $s3->getPath($filename);
$path = $this->s3->getPath($filename);
if (!$s3->exists($path)) {
if (!$this->s3->exists($path)) {
Console::error('File: ' . $path . ' does not exist on cloud');
Console::exit();
}
$this->log('Downloading: ' . $file);
if (!$s3->transfer($path, $file, $local)) {
if (!$this->s3->transfer($path, $file, $local)) {
Console::error('Error Downloading ' . $file);
Console::exit();
}