Using Heroku for Django Media Files

后端 未结 2 1759
忘了有多久
忘了有多久 2020-11-29 10:16

On the heroku domain, I am not able to load my Media(Images Saved by using ImageField property) file images. However, I am able to see the images saved in the static field i

相关标签:
2条回答
  • 2020-11-29 11:18

    Reason

    Heroku runs your application on dynos and dynos go to sleep after 30 minutes if there is not request comes, this makes Heroku not preserve user upload media files between dynos restart.

    Solution

    Use Amazon S3 service for storing and serving media files + you can also serve static files from S3 also. for documentation refer here.

    0 讨论(0)
  • 2020-11-29 11:20

    The Heroku filesystem is ephemeral, so dynos boot with a clean copy of the filesystem from the most recent deploy. Here are some ways to work around this:

    1. AWS S3
    2. If you don't want to set up an account with AWS to create an S3 bucket, Heroku has add-ons that handle storage and processing of static assets

    For more details on this issue, see https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted

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