diff --git a/src/Services/Cloud/Aws.php b/src/Services/Cloud/Aws.php new file mode 100644 index 000000000..e6055b250 --- /dev/null +++ b/src/Services/Cloud/Aws.php @@ -0,0 +1,56 @@ +getConfigFor($source); + + $client = new S3Client($config); + + $adapter = new AwsS3Adapter($client, $config['bucket'], $config['root']); + + return new Filesystem($adapter); + } + + public function getConfigFor($disk) + { + return [ + 'credentials' => [ + 'key' => $this->config($disk, 'key'), + + 'secret' => $this->config($disk, 'secret'), + ], + + 'region' => $this->config($disk, 'region'), + + 'root' => $this->config($disk, 'root', ''), + + 'bucket' => $this->config($disk, 'bucket'), + + 'version' => $this->config($disk, 'version', 'latest'), + ]; + } + + public function config($disk, $key, $default = null) + { + $env1 = Str::upper(Str::snake($disk)); + + $env2 = $env1 === 'AWS' ? 'S3' : 'AWS'; + + $envSuffix = Str::upper($key); + + if (filled($value = config("filesystems.disks.{$disk}.{$key}"))) { + return $value; + } + + return env("{$env1}_{$envSuffix}", env("{$env2}_{$envSuffix}", $default)); + } +} diff --git a/src/Services/Cloud/Azure.php b/src/Services/Cloud/Azure.php new file mode 100644 index 000000000..2b395319e --- /dev/null +++ b/src/Services/Cloud/Azure.php @@ -0,0 +1,13 @@ +filesystemFactory($source); + } + + if ($source == 'azure') { + return app(Azure::class)->filesystemFactory($source); + } + + return $source; + } +}