From 8c73b595c318908ca17659cd4d8f527d0134c7d5 Mon Sep 17 00:00:00 2001 From: Sheharyar Naseem Date: Sun, 1 Jul 2018 18:20:32 +0500 Subject: [PATCH] Fxed `public function readStream($path)` i have fixed `public function readStream($path)` regarding issue https://github.com/jacobcyl/Aliyun-oss-storage/issues/16 --- src/AliOssAdapter.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/AliOssAdapter.php b/src/AliOssAdapter.php index 54d8703..3f448cc 100644 --- a/src/AliOssAdapter.php +++ b/src/AliOssAdapter.php @@ -446,13 +446,18 @@ public function read($path) /** * {@inheritdoc} */ - public function readStream($path) - { + public function readStream($path) { $result = $this->readObject($path); + if (gettype($result['raw_contents']) === 'string') { + $resource = fopen('php://temp', 'r+'); + fwrite($resource, $result['raw_contents']); + $result['raw_contents'] = $resource; + } $result['stream'] = $result['raw_contents']; rewind($result['stream']); // Ensure the EntityBody object destruction doesn't close the stream - $result['raw_contents']->detachStream(); + if (gettype($result['raw_contents']) !== 'resource') + $result['raw_contents']->detachStream(); unset($result['raw_contents']); return $result;