From: Vincent Vanwaelscappel Date: Tue, 5 Nov 2024 16:57:12 +0000 (+0100) Subject: wip #7175 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=c004a458a533a6724cf8364817125c9da0a48278;p=cubist_net.git wip #7175 --- diff --git a/src/Transfer/IServer.php b/src/Transfer/IServer.php index 183b30c..0774205 100644 --- a/src/Transfer/IServer.php +++ b/src/Transfer/IServer.php @@ -69,6 +69,8 @@ interface IServer */ public function getBucket(); + public function getS3Provider(); + public function makeURL($path); } diff --git a/src/Transfer/S3.php b/src/Transfer/S3.php index 4195c94..4573928 100644 --- a/src/Transfer/S3.php +++ b/src/Transfer/S3.php @@ -23,7 +23,7 @@ class S3 extends Driver public function checkConnexion($data = []) { $test = 'test' . time() . '-' . rand(1, 1000000); - $testFile = $data['base_path'] . '/' . $test . '.txt'; + $testFile = trim($data['base_path'], '/') . '/' . $test . '.txt'; $client = $this->createClient($data); @@ -55,20 +55,27 @@ class S3 extends Driver 'bucket' => $data['bucket'] ?? $this->getServer()->getBucket(), 'endpoint' => $data['endpoint'] ?? $this->getServer()->getEndpoint(), 'base_path' => trim($data['base_path'] ?? $this->getServer()->getBasePath(), "/"), + 'provider' => $data['s3_provider'] ?? $this->getServer()->getS3Provider(), ]; return ['region' => $data['region'], 'version' => '2006-03-01', - 'use_path_style_endpoint' => false, + 'endpoint' => $data['endpoint'], + 'use_path_style_endpoint' => static::usePathStyleEndpoint($data['provider']), 'credentials' => ['key' => $data['access_key'], 'secret' => $data['secret']] ]; } + public static function usePathStyleEndpoint($provider) + { + return $provider !== 'AWS'; + } + protected function synchronizeFiles($source, $dest, $mirror = false, $dryrun = false) { $rclone = new Rclone(); - $rclone->setArg(); + $rclone->setArg(); $rclone->setSrc($source); $rclone->setDest(rtrim($this->getServer()->getBasePath(), '/') . '/' . trim($dest, '/') . '/'); $rclone->setMirror($mirror);