Created
October 14, 2015 07:32
-
-
Save jhesyong/e650a0e7f1f9d580d6f1 to your computer and use it in GitHub Desktop.
Get presigned url of private file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getFilePathAttribute($value) | |
{ | |
$disk = Storage::disk('s3'); | |
if ($disk->exists($value)) { | |
$command = $disk->getDriver()->getAdapter()->getClient()->getCommand('GetObject', [ | |
'Bucket' => Config::get('filesystems.disks.s3.bucket'), | |
'Key' => $value, | |
]); | |
$request = $disk->getDriver()->getAdapter()->getClient()->createPresignedRequest($command, '+5 minutes'); | |
return (string) $request->getUri(); | |
} | |
return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment