Skip to content

Instantly share code, notes, and snippets.

@vocolboy
Created July 1, 2017 03:44
Show Gist options
  • Save vocolboy/b44ce5f4a44137632dfdf5cd04365a02 to your computer and use it in GitHub Desktop.
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
$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