Hello,
I am trying to launch an app that requires users to create an account (which triggers a personal folder being created) and then upload a small .rtf file (about 20kb) to their folder (for the app to read from). While running locally, this works flawlessly, but when trying to create a new folder or even just upload a file, I am getting errors.
The error for creating a folder:
Traceback (most recent call last):
File "/opt/render/project/src/.venv/lib/python3.10/site-packages/flask/app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
File "/opt/render/project/src/.venv/lib/python3.10/site-packages/flask/app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/render/project/src/.venv/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/render/project/src/.venv/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/opt/render/project/src/main.py", line 94, in register
os.mkdir(path)
FileNotFoundError: [Errno 2] No such file or directory: './uploads/folder'
The error for uploading a file:
Traceback (most recent call last):
File "/opt/render/project/src/.venv/lib/python3.10/site-packages/flask/app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
File "/opt/render/project/src/.venv/lib/python3.10/site-packages/flask/app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/render/project/src/.venv/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/render/project/src/.venv/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/opt/render/project/src/main.py", line 60, in home
form.file.data.save(f'./uploads/{current_user.name}/' + filename)
File "/opt/render/project/src/.venv/lib/python3.10/site-packages/werkzeug/datastructures/file_storage.py", line 121, in save
dst = open(dst, "wb")
FileNotFoundError: [Errno 2] No such file or directory: './uploads/alinaaaaaaaa/Untitled.rtf'
This is the code used when creating a new folder (triggered automatically after a new user registration):
path = './uploads/' + new_user.name
os.mkdir(path)
This is the code used when uploading a new file (to a user’s folder):
if form.validate_on_submit():
filename = secure_filename(form.file.data.filename)
form.file.data.save(f'./uploads/{current_user.name}/' + filename)
These are the last 2 hurdles that I am facing, so hopefully someone can help and the app can be launched. Many thanks in advance!! <3
P.S. I’ve only started learning Python 2 months ago, so treat me like I am a newb, please.
Later edit: on some user accounts, it works flawlessly, on others it doesn’t. Is there a way to check the contents of the “uploads” folder and see if the problem accounts maybe simply didn’t have their “personal” folder created?
Also, can I view the contents of the database attached through the environment and edit it? Would like to wipe it clean…