Skip to content

Commit 36984fb

Browse files
authored
Merge pull request #1900 from area17/aws
[2.x] Support multiple aws adapters.
2 parents 09ab479 + a92a022 commit 36984fb

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"imgix/imgix-php": "^3.0",
3434
"laravel/framework": "~5.6|~5.7|~5.8|^6.0|^7.0|^8.0|^9.0",
3535
"laravel/socialite": "^4.2|^5.0",
36-
"laravel/ui": "^1.0|^2.0|^3.0",
36+
"laravel/ui": "^1.0|^2.0|^3.0|^4.0",
3737
"league/flysystem-aws-s3-v3": "^1.0|^2.0|^3.0",
3838
"league/glide-laravel": "^1.0",
3939
"matthewbdaly/laravel-azure-storage": "^1.3|^2.0",

src/Services/Cloud/Aws.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Aws\S3\S3Client;
66
use Illuminate\Support\Str;
77
use League\Flysystem\Filesystem;
8-
use League\Flysystem\AwsS3v3\AwsS3Adapter;
98

109
class Aws
1110
{
@@ -15,7 +14,15 @@ public function filesystemFactory($source)
1514

1615
$client = new S3Client($config);
1716

18-
$adapter = new AwsS3Adapter($client, $config['bucket'], $config['root']);
17+
if (class_exists($class = \League\Flysystem\AwsS3v3\AwsS3Adapter::class)) {
18+
$adapter = new $class($client, $config['bucket'], $config['root']);
19+
}
20+
else if (class_exists($class = \League\Flysystem\AwsS3V3\AwsS3V3Adapter::class)) {
21+
$adapter = new $class($client, $config['bucket'], $config['root']);
22+
}
23+
else {
24+
throw new \Exception('Missing compatible aws adapter.');
25+
}
1926

2027
return new Filesystem($adapter);
2128
}

0 commit comments

Comments
 (0)