优化打包类

This commit is contained in:
JaguarJack 2020-05-22 15:45:33 +08:00
parent a60880d327
commit 1d1eaa0338

View File

@ -3,6 +3,7 @@ namespace catcher\library;
use catcher\CatchAdmin; use catcher\CatchAdmin;
use catcher\exceptions\FailedException; use catcher\exceptions\FailedException;
use catcher\facade\Http;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\TransferStats; use GuzzleHttp\TransferStats;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
@ -53,13 +54,19 @@ class Compress
* download zip * download zip
* *
* @time 2020年04月30日 * @time 2020年04月30日
* @param $url * @param $remotePackageUrl
* @param $moduleName * @param $moduleName
* @return string * @return string
*/ */
public function download($moduleName) public function download($moduleName, $remotePackageUrl = '')
{ {
return (new Http())->download('', CatchAdmin::directory() . $moduleName .'.zip'); $response = Http::timeout(5)
->options([
'save_to' => stream_for(fopen(CatchAdmin::directory() . $moduleName .'.zip', 'w+'))
])
->get($remotePackageUrl);
return $response->ok();
} }
/** /**