1234567891011121314151617181920212223242526272829 |
- <?php
- use Aws\S3\S3Client;
- use League\Flysystem\AwsS3v3\AwsS3Adapter;
- use League\Flysystem\Filesystem;
- include __DIR__ . '/vendor/autoload.php';
- $client = new S3Client([
- 'credentials' => [
- 'key' => 'iksop',
- 'secret' => '8htoiwn44g204th' ],
- 'endpoint' => 'https://s3.infra.flowdat.com/minio/login',
- 'use_path_style_endpoint' => true,
- 'region' => 'sa-east-1',
- 'version' => 'latest',]);
- $adapter = new AwsS3Adapter($client, 'comp');
- $filesystem = new Filesystem($adapter);
- try{
- $img = $filesystem->readStream($_SERVER["PATH_INFO"]);
- header("Content-Type: image/png");
- echo stream_get_contents($img);
- }catch(League\Flysystem\FileNotFoundException $e){
- $contents = $filesystem->listContents(dirname($_SERVER["PATH_INFO"]));
- foreach($contents as $content){
- ($content["path"]);
- }
- }
|