mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-07 08:52:35 +00:00
Plugins base (#613)
* wip * wip * cleanup * notification channels * phpstan * services * remove server types * refactoring * refactoring
This commit is contained in:
@ -4,13 +4,10 @@
|
||||
|
||||
use App\Exceptions\SSHCommandError;
|
||||
use App\Exceptions\SSHError;
|
||||
use App\SSH\HasS3Storage;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class S3 extends AbstractStorage
|
||||
{
|
||||
use HasS3Storage;
|
||||
|
||||
/**
|
||||
* @throws SSHError
|
||||
*/
|
||||
@ -89,4 +86,25 @@ public function delete(string $src): void
|
||||
'delete-from-s3'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SSHError
|
||||
*/
|
||||
private function prepareS3Path(string $path, string $prefix = ''): string
|
||||
{
|
||||
$path = trim($path);
|
||||
$path = ltrim($path, '/');
|
||||
$path = preg_replace('/[^a-zA-Z0-9\-_\.\/]/', '_', $path);
|
||||
$path = preg_replace('/\/+/', '/', (string) $path);
|
||||
|
||||
if ($prefix !== '' && $prefix !== '0') {
|
||||
return trim($prefix, '/').'/'.$path;
|
||||
}
|
||||
|
||||
if ($path === null) {
|
||||
throw new SSHError('Invalid S3 path');
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user