|
17 | 17 | use Utopia\Storage\Device\S3; |
18 | 18 | use Utopia\Storage\Device\Wasabi; |
19 | 19 | use Utopia\Storage\Storage; |
20 | | -use Utopia\System\System; |
21 | 20 |
|
22 | 21 | abstract class Adapter |
23 | 22 | { |
@@ -135,7 +134,7 @@ protected function getStorageDevice( |
135 | 134 | string $root, |
136 | 135 | string $region = '' |
137 | 136 | ): Device { |
138 | | - $connections = System::getEnv('OPR_EXECUTOR_CONNECTION_STORAGE', '') ?? ''; |
| 137 | + $connections = Http::getEnv('OPR_EXECUTOR_CONNECTION_STORAGE', '') ?? ''; |
139 | 138 |
|
140 | 139 | if (\preg_match('/^\w+=/', $connections)) { |
141 | 140 | // Multi region |
@@ -170,13 +169,16 @@ protected function getStorageDevice( |
170 | 169 | $bucket = $dsn->getPath() ?? ''; |
171 | 170 | $region = $dsn->getParam('region'); |
172 | 171 | $insecure = $dsn->getParam('insecure', 'false') === 'true'; |
| 172 | + $url = Http::getEnv('OPR_EXECUTOR_STORAGE_S3_ENDPOINT', ''); |
173 | 173 | } catch (\Exception $e) { |
174 | 174 | Console::warning($e->getMessage() . 'Invalid DSN. Defaulting to Local device.'); |
175 | 175 | } |
176 | 176 |
|
177 | 177 | switch ($device) { |
178 | 178 | case Storage::DEVICE_S3: |
179 | | - if (!empty($host)) { |
| 179 | + if (!empty($url)) { |
| 180 | + return new S3($root, $accessKey, $accessSecret, $url, $region, $acl); |
| 181 | + } elseif (!empty($host)) { |
180 | 182 | $host = $insecure ? 'http://' . $host : $host; |
181 | 183 | return new S3(root: $root, accessKey: $accessKey, secretKey: $accessSecret, host: $host, region: $region, acl: $acl); |
182 | 184 | } else { |
@@ -207,7 +209,11 @@ protected function getStorageDevice( |
207 | 209 | $s3Region = Http::getEnv('OPR_EXECUTOR_STORAGE_S3_REGION', '') ?? ''; |
208 | 210 | $s3Bucket = Http::getEnv('OPR_EXECUTOR_STORAGE_S3_BUCKET', '') ?? ''; |
209 | 211 | $s3Acl = 'private'; |
210 | | - if (!empty($s3Host)) { |
| 212 | + $s3EndpointUrl = Http::getEnv('OPR_EXECUTOR_STORAGE_S3_ENDPOINT', ''); |
| 213 | + if (!empty($s3EndpointUrl)) { |
| 214 | + $bucketRoot = (!empty($s3Bucket) ? $s3Bucket . '/' : '') . \ltrim($root, '/'); |
| 215 | + return new S3($bucketRoot, $s3AccessKey, $s3SecretKey, $s3EndpointUrl, $s3Region, $s3Acl); |
| 216 | + } elseif (!empty($s3Host)) { |
211 | 217 | return new S3(root: $root, accessKey: $s3AccessKey, secretKey: $s3SecretKey, host: $s3Host, region: $s3Region, acl: $s3Acl); |
212 | 218 | } else { |
213 | 219 | return new AWS(root: $root, accessKey: $s3AccessKey, secretKey: $s3SecretKey, bucket: $s3Bucket, region: $s3Region, acl: $s3Acl); |
|
0 commit comments