📜  如何在 s3 laravel 中获取私有图像 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:45.726000             🧑  作者: Mango

代码示例1
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();