can retrieve image from s3 laravel code example

Example 1: how to get private images in s3 laravel

use Storage;
use Config;

$client = Storage::disk('s3')->getDriver()->getAdapter()->getClient();
$bucket = Config::get('filesystems.disks.s3.bucket');

$command = $client->getCommand('GetObject', [
    'Bucket' => $bucket,
    'Key' => '344772707_360.mp4'  // file name in s3 bucket which you want to access
]);

$request = $client->createPresignedRequest($command, '+20 minutes');

// Get the actual presigned-url
echo $presignedUrl = (string)$request->getUri();

Example 2: check the existing image in s3 laravel

{!!Html::image(<Your S3 bucket URL>.$myPath),'logo',['width'=>60,'height'=>55])!!}

Tags:

Php Example