spatie media library retrieve media from url

109

spatie media library retrieve media from url -

//To retrieve files you can use the getMedia-method:
$mediaItems = $yourModel->getMedia();
//The method returns a collection of Media-objects.


//You can retrieve the url and path to the file associated with the Media-object using getUrl, getTemporaryUrl (for S3 only) and getPath:
$publicUrl = $mediaItems[0]->getUrl();
$publicFullUrl = $mediaItems[0]->getFullUrl(); //url including domain
$fullPathOnDisk = $mediaItems[0]->getPath();
$temporaryS3Url = $mediaItems[0]->getTemporaryUrl(Carbon::now()->addMinutes(5));

Comments

Submit
0 Comments