You are viewing the documentation for an older version of this package. You can check the version you are using with the following command:
composer show spatie/laravel-medialibrary
Using a custom media downloader
By default, when using the addMediaFromUrl method, the package internally uses fopen to download the media. In some cases though, the media can be behind a firewall or you need to attach specific headers to get access.
To do that, you can specify your own Media Downloader by creating a class that implements the Downloader interface. This method must fetch the resource and return the location of the temporary file.
For example, consider the following example which uses curl with custom headers to fetch the media.