I've just found out that on the DefaultUrlGenerator overriding class, the getUrl() method, if I manually add profile-avatar in this case, then it works perfectly: it returns profile-avatar before the uuid. But the thing is that, shouldn't it be automatically, depending on the collection name itself? I have 2 other storage links.
Spatie MediaLibrary not appending collection name
Today I woke up and saw that my uploaded media (picture) is not appearing correctly. I use spatie/medialibrary. I use echo Auth::user()->getFirstMediaUrl('profile-avatar'); and it returns domain/uuid/... instead of domain/profile-avatar/uuid/..
I overrided the Spatie\MediaLibrary\Support\PathGenerator\PathGenerator;, and also Spatie\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator; because I use stancl/tenancy package and I want to make all the files tenant-aware.
If I add the collection name (profile-avatar) manually after domain/ then it works perfectly.
Is this an issue with getUrl() method? Where should I check?
Regards.
I've fixed it!
On the getUrl() method, the $url variable should be:
$url = asset($this->getDiskName().'/'.$this->getPathRelativeToRoot());
I have added $this->getDiskName().'/'.
And it works well for both (or any) storages.
I don't know what's happening, for real. One day I wake up and suddenly, most unexpected problems appear.
Please or to participate in this conversation.