Skip to content

Commit

Permalink
Merge pull request #1900 from area17/aws
Browse files Browse the repository at this point in the history
[2.x] Support multiple aws adapters.
  • Loading branch information
haringsrob authored Nov 9, 2022
2 parents 09ab479 + a92a022 commit 36984fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"imgix/imgix-php": "^3.0",
"laravel/framework": "~5.6|~5.7|~5.8|^6.0|^7.0|^8.0|^9.0",
"laravel/socialite": "^4.2|^5.0",
"laravel/ui": "^1.0|^2.0|^3.0",
"laravel/ui": "^1.0|^2.0|^3.0|^4.0",
"league/flysystem-aws-s3-v3": "^1.0|^2.0|^3.0",
"league/glide-laravel": "^1.0",
"matthewbdaly/laravel-azure-storage": "^1.3|^2.0",
Expand Down
11 changes: 9 additions & 2 deletions src/Services/Cloud/Aws.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Aws\S3\S3Client;
use Illuminate\Support\Str;
use League\Flysystem\Filesystem;
use League\Flysystem\AwsS3v3\AwsS3Adapter;

class Aws
{
Expand All @@ -15,7 +14,15 @@ public function filesystemFactory($source)

$client = new S3Client($config);

$adapter = new AwsS3Adapter($client, $config['bucket'], $config['root']);
if (class_exists($class = \League\Flysystem\AwsS3v3\AwsS3Adapter::class)) {
$adapter = new $class($client, $config['bucket'], $config['root']);
}
else if (class_exists($class = \League\Flysystem\AwsS3V3\AwsS3V3Adapter::class)) {
$adapter = new $class($client, $config['bucket'], $config['root']);
}
else {
throw new \Exception('Missing compatible aws adapter.');
}

return new Filesystem($adapter);
}
Expand Down

0 comments on commit 36984fb

Please sign in to comment.