@@ -95,11 +95,17 @@ protected function parseParams($params) {
9595 $ this ->copySizeLimit = $ params ['copySizeLimit ' ] ?? 5242880000 ;
9696 $ this ->useMultipartCopy = (bool )($ params ['useMultipartCopy ' ] ?? true );
9797 $ params ['region ' ] = empty ($ params ['region ' ]) ? 'eu-west-1 ' : $ params ['region ' ];
98+ $ params ['s3-accelerate ' ] = $ params ['hostname ' ] == 's3-accelerate.amazonaws.com ' || $ params ['hostname ' ] == 's3-accelerate.dualstack.amazonaws.com ' ;
9899 $ params ['hostname ' ] = empty ($ params ['hostname ' ]) ? 's3. ' . $ params ['region ' ] . '.amazonaws.com ' : $ params ['hostname ' ];
99100 if (!isset ($ params ['port ' ]) || $ params ['port ' ] === '' ) {
100101 $ params ['port ' ] = (isset ($ params ['use_ssl ' ]) && $ params ['use_ssl ' ] === false ) ? 80 : 443 ;
101102 }
102103 $ params ['verify_bucket_exists ' ] = $ params ['verify_bucket_exists ' ] ?? true ;
104+
105+ if ($ params ['s3-accelerate ' ]) {
106+ $ params ['verify_bucket_exists ' ] = false ;
107+ }
108+
103109 $ this ->params = $ params ;
104110 }
105111
@@ -146,6 +152,13 @@ public function getConnection() {
146152 'http ' => ['verify ' => $ this ->getCertificateBundlePath ()],
147153 'use_aws_shared_config_files ' => false ,
148154 ];
155+
156+ if ($ this ->params ['s3-accelerate ' ]) {
157+ $ options ['use_accelerate_endpoint ' ] = true ;
158+ } else {
159+ $ options ['endpoint ' ] = $ base_url ;
160+ }
161+
149162 if ($ this ->getProxy ()) {
150163 $ options ['http ' ]['proxy ' ] = $ this ->getProxy ();
151164 }
@@ -174,7 +187,9 @@ public function getConnection() {
174187 'exception ' => $ e ,
175188 'app ' => 'objectstore ' ,
176189 ]);
177- throw new \Exception ('Creation of bucket " ' . $ this ->bucket . '" failed. ' . $ e ->getMessage ());
190+ if ($ e ->getAwsErrorCode () !== "BucketAlreadyOwnedByYou " ) {
191+ throw new \Exception ('Creation of bucket " ' . $ this ->bucket . '" failed. ' . $ e ->getMessage ());
192+ }
178193 }
179194 }
180195
0 commit comments