[Fixed]-Using Heroku for Django Media Files

17👍

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.

9👍

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

Leave a comment