Heroku, accesing laravel storage folder

后端 未结 1 925
灰色年华
灰色年华 2021-01-26 01:27

When the button clicked, it is supposed to open a file of \"resume.pdf\" in a blank page. It works fine with localhost, but when it is executed on heroku, it doesn\'t go through

相关标签:
1条回答
  • 2021-01-26 01:44

    So, this answer has two parts.

    The first is that storage isn't publicly accessible by default. Per the docs:

    To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public. This convention will keep your publicly accessible files in one directory that can be easily shared across deployments when using zero down-time deployment systems like Envoyer.

    (You probably did this locally once, but forgot. Or, your local server is running out of the app's main folder instead of the public subfolder.)

    BUT...

    On Heroku, the filesystem is ephemeral. It is not permanent. Files you store on the instance can go away at any time. If you do a new deploy, or if you scale up/down, or if Heroku needs to restart/replace an instance, alllllll the files your users have uploaded to storage are wiped out.

    Instead, you'll want to store user uploads somewhere like Amazon S3, which Laravel makes easy. Once you've configured your S3 keys, you can just do stuff like Storage::disk('s3') to work with S3 instead of the local, soon-to-be-erased disk.

    0 讨论(0)
提交回复
热议问题