From 68e83f845dec1873324d37f52b2389c73602d509 Mon Sep 17 00:00:00 2001 From: "a.dmitryuk" Date: Tue, 15 Nov 2022 18:37:11 +0700 Subject: [PATCH 1/4] GoogleCloudStorage body can return StreamInterface Fix topic 652 --- src/Gaufrette/Adapter/GoogleCloudStorage.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Gaufrette/Adapter/GoogleCloudStorage.php b/src/Gaufrette/Adapter/GoogleCloudStorage.php index 295dcad1..c8cd1acf 100644 --- a/src/Gaufrette/Adapter/GoogleCloudStorage.php +++ b/src/Gaufrette/Adapter/GoogleCloudStorage.php @@ -10,6 +10,7 @@ use Google\Service\Storage\BucketIamConfiguration; use Google\Service\Storage\BucketIamConfigurationUniformBucketLevelAccess; use GuzzleHttp; +use Psr\Http\Message\StreamInterface; /** * Google Cloud Storage adapter using the Google APIs Client Library for PHP. @@ -125,8 +126,12 @@ public function read($key) $response = $httpClient->request('GET', $object->getMediaLink()); if ($response->getStatusCode() == 200) { $this->setMetadata($key, $object->getMetadata()); + $body = $response->getBody(); + if ($body instanceof StreamInterface) { + return $body->getContents(); + } - return $response->getBody(); + return $body; } } From 5e2402d4e1cc0dde9d7f9b41e02db84f42faa8a4 Mon Sep 17 00:00:00 2001 From: "a.dmitryuk" Date: Tue, 15 Nov 2022 18:39:40 +0700 Subject: [PATCH 2/4] GoogleCloudStorage body can return StreamInterface Fix topic 652 --- src/Gaufrette/Adapter/GoogleCloudStorage.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Gaufrette/Adapter/GoogleCloudStorage.php b/src/Gaufrette/Adapter/GoogleCloudStorage.php index c8cd1acf..9344252c 100644 --- a/src/Gaufrette/Adapter/GoogleCloudStorage.php +++ b/src/Gaufrette/Adapter/GoogleCloudStorage.php @@ -10,7 +10,6 @@ use Google\Service\Storage\BucketIamConfiguration; use Google\Service\Storage\BucketIamConfigurationUniformBucketLevelAccess; use GuzzleHttp; -use Psr\Http\Message\StreamInterface; /** * Google Cloud Storage adapter using the Google APIs Client Library for PHP. @@ -126,12 +125,7 @@ public function read($key) $response = $httpClient->request('GET', $object->getMediaLink()); if ($response->getStatusCode() == 200) { $this->setMetadata($key, $object->getMetadata()); - $body = $response->getBody(); - if ($body instanceof StreamInterface) { - return $body->getContents(); - } - - return $body; + return (string)$response->getBody(); } } From d26a82ea8b781a75ac409611be32ff1cc8f0b1c4 Mon Sep 17 00:00:00 2001 From: "a.dmitryuk" Date: Tue, 15 Nov 2022 18:40:11 +0700 Subject: [PATCH 3/4] GoogleCloudStorage body can return StreamInterface Fix topic 652 --- src/Gaufrette/Adapter/GoogleCloudStorage.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Gaufrette/Adapter/GoogleCloudStorage.php b/src/Gaufrette/Adapter/GoogleCloudStorage.php index 9344252c..4761ab30 100644 --- a/src/Gaufrette/Adapter/GoogleCloudStorage.php +++ b/src/Gaufrette/Adapter/GoogleCloudStorage.php @@ -125,6 +125,7 @@ public function read($key) $response = $httpClient->request('GET', $object->getMediaLink()); if ($response->getStatusCode() == 200) { $this->setMetadata($key, $object->getMetadata()); + return (string)$response->getBody(); } } From 1766571a1aa6b342b64879e6c5b6272d2ef1086e Mon Sep 17 00:00:00 2001 From: "a.dmitryuk" Date: Thu, 1 Dec 2022 10:28:04 +0700 Subject: [PATCH 4/4] cs-fixer --- src/Gaufrette/Adapter/GoogleCloudStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gaufrette/Adapter/GoogleCloudStorage.php b/src/Gaufrette/Adapter/GoogleCloudStorage.php index 4761ab30..f2a37390 100644 --- a/src/Gaufrette/Adapter/GoogleCloudStorage.php +++ b/src/Gaufrette/Adapter/GoogleCloudStorage.php @@ -126,7 +126,7 @@ public function read($key) if ($response->getStatusCode() == 200) { $this->setMetadata($key, $object->getMetadata()); - return (string)$response->getBody(); + return (string) $response->getBody(); } }