diff --git a/src/helpers/AssetHelper.php b/src/helpers/AssetHelper.php index e05ea30d..2ab0ecb3 100644 --- a/src/helpers/AssetHelper.php +++ b/src/helpers/AssetHelper.php @@ -53,10 +53,25 @@ public static function downloadFile($srcName, $dstName, int $chunkSize = 1, bool return fclose($fp); } + $fp = fopen($dstName, 'wb'); + + $assetDownloadGuzzle = Plugin::$plugin->service->getConfig('assetDownloadGuzzle', $feedId); + if ($assetDownloadGuzzle) { + $response = null; + $client = Plugin::$plugin->service->createGuzzleClient(); + try { + $response = $client->get($srcName, ['sink' => $fp]); + } catch (Throwable $e) { + } + + fclose($fp); + + return $response?->getStatusCode() === 200; + } + $newChunkSize = $chunkSize * (1024 * 1024); $bytesCount = 0; $handle = fopen($srcName, 'rb'); - $fp = fopen($dstName, 'wb'); if ($handle === false) { return false; diff --git a/src/models/Settings.php b/src/models/Settings.php index 0016d6ed..4955af91 100644 --- a/src/models/Settings.php +++ b/src/models/Settings.php @@ -102,4 +102,10 @@ class Settings extends Model * @var bool */ public bool $assetDownloadCurl = false; + + /** + * @var bool + * @since 5.9.0 + */ + public bool $assetDownloadGuzzle = false; }