spatie media library retrieve media from url

Solutions on MaxInterview for spatie media library retrieve media from url by the best coders in the world

showing results for - "spatie media library retrieve media from url"
Michela
22 Apr 2019
1//To retrieve files you can use the getMedia-method:
2$mediaItems = $yourModel->getMedia();
3//The method returns a collection of Media-objects.
4
5
6//You can retrieve the url and path to the file associated with the Media-object using getUrl, getTemporaryUrl (for S3 only) and getPath:
7$publicUrl = $mediaItems[0]->getUrl();
8$publicFullUrl = $mediaItems[0]->getFullUrl(); //url including domain
9$fullPathOnDisk = $mediaItems[0]->getPath();
10$temporaryS3Url = $mediaItems[0]->getTemporaryUrl(Carbon::now()->addMinutes(5));