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;