kaycee
kaycee

Reputation: 45

How to display images on Heroku using a Laravel linked storage folder, after entering the 'php artisan storage:link' command?

I'm able to display images from different sources, but I am not able to use a linked folder that would come from using php artisan storage:link. I've tried changing the permissions but no luck. I rather use the linked folder to avoid making copies of the same folders which takes up more space, especially for future projects.

Upvotes: 0

Views: 867

Answers (1)

mwal
mwal

Reputation: 3113

You probably already know this, but Heroku dynos use an emphemeral file system.

The consequence is that if your app ever uploads anything to the storage directory, as you might do in a traditional server environment, that file is guaranteed gone, never to return, within 24 hours because of automatic dyno reboot.

To permanently store files uploaded by your app after it has started, please consider using s3, as per the heroku docs.

In the case of assets that you know you want at dyno launch time, the situation is slightly different. You can commit assets to your repo, in public/, which will then be in your dyno slug. e.g., that's how .css & .js build files will be put up there. Those are known at launch time, and don't change during the operation of your app. These files will of course survive reboots because they are in the slug.

But remember anything that you upload using your app will vanish unless you use an appropriate persistent storage for heroku, i.e., not the dyno's filesystem.

Upvotes: 1

Related Questions