diff --git a/app/Extensions/Filesystem/S3Filesystem.php b/app/Extensions/Filesystem/S3Filesystem.php index 2a3b61a39..daf037e9f 100644 --- a/app/Extensions/Filesystem/S3Filesystem.php +++ b/app/Extensions/Filesystem/S3Filesystem.php @@ -12,6 +12,8 @@ use SimpleXMLElement; class S3Filesystem extends AwsS3V3Adapter { + private ?GuzzleClient $guzzle = null; + /** * @param array $options */ @@ -31,6 +33,18 @@ class S3Filesystem extends AwsS3V3Adapter ); } + private function getGuzzleClient(): GuzzleClient + { + if ($this->guzzle === null) { + $this->guzzle = new GuzzleClient([ + 'timeout' => 30, + 'connect_timeout' => 10, + ]); + } + + return $this->guzzle; + } + public function getClient(): S3ClientInterface { return $this->client; @@ -51,8 +65,7 @@ class S3Filesystem extends AwsS3V3Adapter { $presignedRequest = $this->client->createPresignedRequest($command, '+60 minutes'); - $guzzle = new GuzzleClient(); - $response = $guzzle->send($presignedRequest); + $response = $this->getGuzzleClient()->send($presignedRequest); $body = (string) $response->getBody(); $commandName = $command->getName();