12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace Aws\CloudTrail;
- use Aws\S3\S3Client;
- class LogFileReader
- {
-
- private $s3Client;
-
- public function __construct(S3Client $s3Client)
- {
- $this->s3Client = $s3Client;
- }
-
- public function read($s3BucketName, $logFileKey)
- {
-
- $command = $this->s3Client->getCommand('GetObject', [
- 'Bucket' => (string) $s3BucketName,
- 'Key' => (string) $logFileKey,
- 'ResponseContentEncoding' => 'x-gzip'
- ]);
-
-
- $command['@http']['headers']['Accept-Encoding'] = 'gzip';
-
- $result = $this->s3Client->execute($command);
- $logData = json_decode($result['Body'], true);
- return isset($logData['Records']) ? $logData['Records'] : [];
- }
- }
|