mirror of
https://github.com/pelican-dev/panel.git
synced 2026-05-04 18:00:48 +03:00
Reuse GuzzleClient with timeouts for presigned S3 requests
This commit is contained in:
@@ -12,6 +12,8 @@ use SimpleXMLElement;
|
||||
|
||||
class S3Filesystem extends AwsS3V3Adapter
|
||||
{
|
||||
private ?GuzzleClient $guzzle = null;
|
||||
|
||||
/**
|
||||
* @param array<mixed> $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();
|
||||
|
||||
Reference in New Issue
Block a user