Skip to content

Instantly share code, notes, and snippets.

@bredmor
Created December 9, 2019 21:48
Show Gist options
  • Save bredmor/5ed17622e8dd780c497eb046ffdeea4a to your computer and use it in GitHub Desktop.
Save bredmor/5ed17622e8dd780c497eb046ffdeea4a to your computer and use it in GitHub Desktop.
s3 presigned uri request
/**
* Get presigned url to access xml file directly on s3.
*/
public function getXmlUrlAttribute()
{
$client = Storage::disk('s3')->getAdapter()->getClient();
$command = $client->getCommand('GetObject', [
'Bucket' => config('filesystems.disks.s3.bucket'),
'Key' => $this->xml_path,
]);
return (string) $client
->createPresignedRequest($command, '+7 days')
->getUri();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment