Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 6d7cb61

Browse files
committed
Use Http facade for download
1 parent db3aedc commit 6d7cb61

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Helpers/Migrator.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Jezzdk\StatamicWpImport\Helpers;
44

55
use Exception;
6+
use Illuminate\Support\Facades\Http;
67
use Illuminate\Support\Facades\Storage;
78
use Statamic\Assets\Asset;
89
use Statamic\Facades\AssetContainer;
@@ -244,7 +245,8 @@ private function downloadAsset(string $url = null, string $collection, string $s
244245
}
245246

246247
try {
247-
$image = @file_get_contents($url);
248+
$image = Http::retry(3, 500)->get($url)->body();
249+
248250
$originalImageName = basename($url);
249251

250252
Storage::put($tempFile = 'temp', $image);
@@ -263,6 +265,7 @@ private function downloadAsset(string $url = null, string $collection, string $s
263265

264266
return $asset;
265267
} catch (Exception $e) {
268+
logger('Image download failed: ' . $e->getMessage());
266269
return false;
267270
}
268271
}

0 commit comments

Comments
 (0)