Created
July 1, 2017 03:44
-
-
Save vocolboy/b44ce5f4a44137632dfdf5cd04365a02 to your computer and use it in GitHub Desktop.
aws pre-sign muilt file - with laravel 5.4 & aws-sdk-php-v3
This file contains hidden or 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
$s3 = \Illuminate\Support\Facades\Storage::disk('s3'); | |
$bucket = 'eatgether'; | |
# Get dir Files | |
$files = $s3->allFiles('news'); | |
$client = $s3->getDriver()->getAdapter()->getClient(); | |
$expiry = "+10 minutes"; | |
$result = []; | |
foreach ($files as $file) { | |
$command = $client->getCommand('GetObject', [ | |
'Bucket' => $bucket, | |
'Key' => $file | |
]); | |
$request = $client->createPresignedRequest($command, $expiry); | |
$result[] = (string)$request->getUri(); | |
} | |
return $result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment