新增下载保存地址方法

This commit is contained in:
root 2020-07-11 15:02:05 +08:00
parent 359381fec6
commit e17846571c

View File

@ -11,6 +11,8 @@ use function GuzzleHttp\Psr7\stream_for;
class Compress class Compress
{ {
protected $savePath;
public function __construct() public function __construct()
{ {
if (!extension_loaded('zip')) { if (!extension_loaded('zip')) {
@ -62,7 +64,7 @@ class Compress
{ {
$response = Http::timeout(5) $response = Http::timeout(5)
->options([ ->options([
'save_to' => stream_for(fopen(CatchAdmin::directory() . $moduleName .'.zip', 'w+')) 'save_to' => stream_for(fopen($this->savePath, 'w+'))
]) ])
->get($remotePackageUrl); ->get($remotePackageUrl);
@ -230,4 +232,19 @@ class Compress
{ {
return $backup = runtime_path('module' . DIRECTORY_SEPARATOR . 'backup_'.$moduleName); return $backup = runtime_path('module' . DIRECTORY_SEPARATOR . 'backup_'.$moduleName);
} }
/**
* 保存地址
*
* @param $path
* @return $this
* @author JaguarJack <njphper@gmail.com>
* @date 2020/7/11
*/
public function savePath($path)
{
$this->savePath = $path;
return $this;
}
} }