load(); $env = array_merge($_ENV, $_SERVER); ksort($env); /** @var Aws\S3\S3ClientInterface $client */ $client = new Aws\S3\S3Client([ 'region' => 'ti', 'version' => 'latest', 'endpoint' => $env['S3_ENDPOINT'], 'use_path_style_endpoint' => true, 'credentials' => [ 'key' => $env['S3_KEY'], 'secret' => $env['S3_SECRET'], ], ]); // The internal adapter $adapter = new League\Flysystem\AwsS3V3\AwsS3V3Adapter( // S3Client $client, // Bucket name $env['S3_BUCKET'] ); // The FilesystemOperator $filesystem = new League\Flysystem\Filesystem($adapter); if($env['REQUEST_URI'] == '/') { foreach($filesystem->listContents("/") as $file) { echo "{$file['path']}
"; } }else { if ($filesystem->fileExists($env['REQUEST_URI'])) { // Read file using a stream and output it as a stream $stream = $filesystem->readStream($env['REQUEST_URI']); header('Content-Type: ' . $filesystem->mimeType($env['REQUEST_URI'])); fpassthru($stream); exit; } else { header("HTTP/1.0 404 Not Found"); echo "File not found"; } }