Where should the mediafiles directory be in the Django configuration to be able to download the files on the Heroku server (free app)?

Asked

Viewed 62 times

-2

After uploading the file for hours I can download the files, but after a while I can not download the files, saying that the file does not exist, only when I consult the database and the table by Heroku pg:psql files still appear there.

Can anyone help me? It’s problem in configuration and code?

I used to deploy this tutorial: https://github.com/Gpzim98/django-heroku

python-3.8.1 Django==3.0.5

Follow screenshot of the configuration: inserir a descrição da imagem aqui

1 answer

1

You need to implement a solution that loads to a Bucket or Storage blob, AWS or Azure or GCS, and stores the image/file path/name in the database.

Here is the full explanation of documentation of Heroku:

  • The Heroku file system is ephemeral - it means any file system changes while Dyno is running last only until this Dyno is turned off or restarted. Each Dyno is initialized with a clean copy of the file system plus recent. This is similar to how many container-based systems, like Docker.
  • In addition, in normal operations, dynos will be reset to all days in a process known as "Cycling".
  • These two facts mean that the file system in Heroku is not suitable for persistent data storage or Static files. In cases where you need to store data, recommend using an add-on database, such as Postgres or Mysql (for data) or a dedicated file storage, such as AWS S3 (for files static). If you do not want to set up an AWS account to create a Bucket S3, there are also complements that deal with static file storage and processing.
  • Clearer than impossible, congratulations.

  • Can I do this using some free method and using the free Heroku App? For example by setting up a Docker? I’m a beginner and I just deployed on Heroku.

  • Hey, as for Docker, you don’t have to, I just set an example. Now a free solution, must exist, I do not know or use, I have used almost always Blob Storage from Azure, in the projects I do with Django only a few years ago with Bucket S3 from AWS. In the main providers (in the 3 that I indicated), for example Azure you can create free account for 30 days, but I think it asks for a payment mode in the same, although they do not charge anything, and does not serve virtual cards.

  • Thank you very much for your answers!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.