I built a Django app that has some .txt files in a folder on under the project root dir as shown below.
<pre>
[projectname]/
├── [projectname]/
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── manage.py
├── [<b> myfiles </b>]/
│ ├── file1.txt
│ ├── file2.txt
│ ├── file3.txt
│ └── file4.txt
└── [myApp]/
</pre>
I specify the files paths when I am running the django app on my local machine. Now, I tried running my app on Heroku, but the not app does not work when I tried reference any of my files to do some processing. Is there a way that I can use a file server (external or internal to Heroku) where I can store my files on and then update them in via the django app (by the users) and save them back to file server?
In my app, when a user creates a new project, in the background a function will create a folder for the user and then copy the files in [myfiles] folder to the user's new project folder.
Also, users can enter data through forms that I want to to save to .rdf files and then save to the file server.
In the end, I the file system would look like this:
<pre>
[file system root]/
├── [<b> myfiles </b>]/
│ ├── file1.txt
│ ├── file2.txt
│ ├── file3.txt
│ └── file4.txt
├── [<b> user1 </b>]/
│ ├── file1.txt
│ ├── file2.txt
│ ├── file3.txt
│ └── graphfile1
├── [<b> user2 </b>]/
│ ├── file1.txt
│ ├── graphfile1
│ ├── file3.txt
│ └── file4.txt
├── [<b> user3 </b>]/
│ ├── file1.txt
│ ├── file2.txt
│ ├── graphfile1
│ └── file4.txt
....
</pre>
You need to use a service like S3, use django-storages package.
And one thing, in Heroku the data is not persistent. Every time the dyno is restart, the files restart to the original image too. More info here: https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.