Skip to content

Commit

Permalink
fix the rewind
Browse files Browse the repository at this point in the history
  • Loading branch information
Ping Cheng committed Nov 28, 2018
1 parent e7b7fe5 commit 6830e86
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/AliOssAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,15 @@ public function read($path)
public function readStream($path)
{
$result = $this->readObject($path);
$result['stream'] = $result['raw_contents'];
if (is_resource($result['raw_contents'])) {
$result['stream'] = $result['raw_contents'];
// Ensure the EntityBody object destruction doesn't close the stream
$result['raw_contents']->detachStream();
} else {
$result['stream'] = fopen('php://temp', 'r+');
fwrite($result['stream'], $result['raw_contents']);
}
rewind($result['stream']);
// Ensure the EntityBody object destruction doesn't close the stream
$result['raw_contents']->detachStream();
unset($result['raw_contents']);

return $result;
}

Expand Down

0 comments on commit 6830e86

Please sign in to comment.