an920107 / health-care-website

中央大學衛保組網站 NCU Health Care
https://health.ncu.edu.tw
MIT License
2 stars 0 forks source link

[Backend] Error when upload carousel #78

Closed an920107 closed 1 week ago

an920107 commented 2 weeks ago

Steps

Logs

Content
[2024-08-30 15:28:21,562] ERROR in app: Exception on /api/carousel [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask_cors/extension.py", line 178, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
                                                ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/helpers/auth_helpers.py", line 20, in wrapper
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/app/blueprints/carousel_blueprint.py", line 175, in post_carousel
    image.save(new_file_path)
  File "/usr/local/lib/python3.11/site-packages/werkzeug/datastructures/file_storage.py", line 125, in save
    dst = open(dst, "wb")
          ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'statics/carousels/cf707a38-ddbc-45bc-a3fc-633fe9c45792.png'
122.116.74.59 - - [30/Aug/2024 15:28:21] "POST /api/carousel HTTP/1.0" 500 -
an920107 commented 2 weeks ago

I guess the reason is the folder statics/carousel wasn't created automatically. I've ceated the one and the problem is temporarily solved.

Xunhaoz commented 1 week ago

Bug was fixed. It happened because of error storing path.