tanmay_das's avatar

Confusions about laravel storage directory and its symlink

Okay, this is what I understand about the laravel storage so far:

All my public assets, things like profile pictures or any user-generated files should reside in myapp/storage/app/public and things that are not user-generated, but application-specific, such as: logo, banner etc., should reside outside the public directory. For instance, myapp/storage/app/private.

We create a symlink within the myapp/public/ directory that points to myapp/storage/app/public/ and we access our public assets by asset('storage/avatar.png'). It loads the avatar from myapp/storage/app/public/avatar.png

But how do I access my private assets? Say I want to load my logo.png file which is in myapp/storage/app/private/logo.png this path?

0 likes
3 replies
tanmay_das's avatar

@mhankins It's not working. Maybe because it's pointing to /media/tanmay/3806FF1D11D87FF6/code/myapp/storage/app/private/logo.png, which translates into this:

http://localhost:3000/media/tanmay/3806FF1D11D87FF6/code/myapp/storage/app/private/logo.png

instead of being translated into this:

http://localhost:3000/storage/app/private/logo.png

...relative to my application, not my entire disk (media/tanmay/blah/....).

And I just realized it will never get past the storage/app directory, since the symlink in the public (http://localhost:3000/) directory is always pointing to storage/app/public/

The only solution I can see is to put my private assets in public directory :(

tanmay_das's avatar

Anything that's visible in the browser, shouldn't it be considered public? And if that's the case, shouldn't logo, banner etc. be considered public too?

Please or to participate in this conversation.