]> _ Git - cubist_net.git/commitdiff
wip #7175
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 5 Nov 2024 16:57:12 +0000 (17:57 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 5 Nov 2024 16:57:12 +0000 (17:57 +0100)
src/Transfer/IServer.php
src/Transfer/S3.php

index 183b30cc229d0ff75d649190f5aa52ed1a16e2eb..0774205fc291a01621fca2d3d8c0f95656077896 100644 (file)
@@ -69,6 +69,8 @@ interface IServer
      */
     public function getBucket();
 
+    public function getS3Provider();
+
     public function makeURL($path);
 
 }
index 4195c94f20b90c569ef656901c39040408862a10..45739284513f869fbf58cb13ecf98cf69cbcc8da 100644 (file)
@@ -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);