laravel-mediable: $media->getUrl() triggers errors after upgrading to Version 3

Several trouble after upgrading to laravel version 6 and laravel-mediable version 3.

Please note that everything was passing before upgrading to V 3.

I am testing on local public disk. During test I was accessing $media->getUrl() and facing errors.

When I do Storage:fake(): Storage::fake(); $uploadedFile = UploadedFile::fake()->image(‘photo.jpeg’, 20, 20);

I am getting following error (formatted): “message:” “strpos() expects parameter 1 to be string, bool given” “exception:” “Symfony\Component\Debug\Exception\FatalThrowableError” “file:” “/var/www/watchcrunch/vendor/plank/laravel-mediable/src/UrlGenerators/LocalUrlGenerator.php” “line:” 100 “trace-first:” array:3 [ “file” => “/var/www/watchcrunch/vendor/plank/laravel-mediable/src/UrlGenerators/LocalUrlGenerator.php” “line” => 100 “function” => “strpos” ]

When I don’t fake Storage:fake() //Storage::fake(); $uploadedFile = UploadedFile::fake()->image(‘photo.jpeg’, 20, 20);

I am getting following error (formatted): “message:” “Media file /var/www/watchcrunch/storage/app/public/photos/2019/09/O1TtRmb6kBfBCyQsfCgAXGiBCCFfOubbeoxgH0H2.jpeg is not part of the public path /var/www/watchcrunch/public” “exception:” “Plank\Mediable\Exceptions\MediaUrlException” “file:” “/var/www/watchcrunch/vendor/plank/laravel-mediable/src/Exceptions/MediaUrlException.php” “line:” 26 “trace-first:” array:5 [ “file” => “/var/www/watchcrunch/vendor/plank/laravel-mediable/src/UrlGenerators/LocalUrlGenerator.php” “line” => 44 “function” => “mediaNotPubliclyAccessible” “class” => “Plank\Mediable\Exceptions\MediaUrlException” “type” => “::” ]

After some further digging I found, my file is not considered as public at all although disk has public visibility and even adding makePublic() during upload.

Also I guess the issue may be in LocalUrlGenerated function isInWebroot().

However for S3 driver everything works well as expected.

Can anyone help? Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Ageed that we should probably sync up with the underlying Laravel Filesystem/Flysystem change, though that would be a slightly breaking change as it looks this will remove support for the “prefix” config option, and require a “url” option to be defined on the disk (otherwise you get a root-relative URL instead of an absolute URL).

I will try to put up a PR tomorrow.