File "DefaultDownloader.php"
Full Path: /home/clickysoft/public_html/jmapi5.clickysoft.net/vendor/spatie/laravel-medialibrary/src/Downloaders/DefaultDownloader.php
File size: 696 bytes
MIME-type: text/x-php
Charset: utf-8
<?php
namespace Spatie\MediaLibrary\Downloaders;
use Spatie\MediaLibrary\MediaCollections\Exceptions\UnreachableUrl;
class DefaultDownloader implements Downloader
{
public function getTempFile(string $url): string
{
$context = stream_context_create([
"http" => [
"header" => "User-Agent: Spatie MediaLibrary",
],
]);
if (! $stream = @fopen($url, 'r', false, $context)) {
throw UnreachableUrl::create($url);
}
$temporaryFile = tempnam(sys_get_temp_dir(), 'media-library');
file_put_contents($temporaryFile, $stream);
fclose($stream);
return $temporaryFile;
}
}