Browse Source

[api] Add workaround to fix regular file upload API (#3962)

Harsh Gupta 10 months ago
parent
commit
17e4f36123
1 changed files with 6 additions and 0 deletions
  1. 6 0
      desktop/core/src/desktop/middleware.py

+ 6 - 0
desktop/core/src/desktop/middleware.py

@@ -206,6 +206,12 @@ class ClusterMiddleware(MiddlewareMixin):
   """
   Manages setting request.fs and request.jt
   """
+  def process_request(self, request):
+    # Workaround to prevent RawPostDataException: Store the request body for later access
+    # This is necessary because certain API calls (like file uploads) require the raw request body
+    # to be available. Without this, subsequent accesses to request.body might raise exceptions.
+    request._body = request.body
+
   def process_view(self, request, view_func, view_args, view_kwargs):
     """
     Sets request.fs and request.jt on every request to point to the configured filesystem.