diff --git a/src/Qcloud/Cos/ResultTransformer.php b/src/Qcloud/Cos/ResultTransformer.php index 02afc84c..7764e427 100644 --- a/src/Qcloud/Cos/ResultTransformer.php +++ b/src/Qcloud/Cos/ResultTransformer.php @@ -33,7 +33,15 @@ public function writeDataToLocal(CommandInterface $command, RequestInterface $re if ($action == "GetObject") { if (isset($command['SaveAs'])) { $fp = fopen($command['SaveAs'], "wb"); - fwrite($fp, $response->getBody()); + $stream = $response->getBody(); + $offset = 0; + $partsize = 8192; + while (!$stream->eof()) { + $output = $stream->read($partsize); + fseek($fp, $offset); + fwrite($fp, $output); + $offset += $partsize; + } fclose($fp); } }