From ff9704fc0ebe9b555f41cde1449e2b06de4427dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20R=C3=A4dle?= Date: Tue, 8 Oct 2024 14:58:27 -0700 Subject: [PATCH] [sam2][demo][1/x] Fix file upload Summary: The Strawberry GraphQL library recently disabled multipart requests by default. This resulted in a video upload request returning "Unsupported content type" instead of uploading the video, processing it, and returning the video path. This issue was raised in #361. A forward fix is to add `multipart_uploads_enabled=True` to the endpoint view. Test Plan: Tested locally with cURL and upload succeeds *Request* ``` curl http://localhost:7263/graphql \ -F operations='{ "query": "mutation($file: Upload!){ uploadVideo(file: $file) { path } }", "variables": { "file": null } }' \ -F map='{ "file": ["variables.file"] }' \ -F file=@video.mov ``` *Response* ``` {"data": {"uploadVideo": {"path": "uploads/.mp4"}}} ``` --- demo/backend/server/app.py | 4 ++++ setup.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/demo/backend/server/app.py b/demo/backend/server/app.py index 9902f475..424e85bb 100644 --- a/demo/backend/server/app.py +++ b/demo/backend/server/app.py @@ -128,6 +128,10 @@ def get_context(self, request: Request, response: Response) -> Any: # https://strawberry.rocks/docs/operations/deployment # https://strawberry.rocks/docs/integrations/flask allow_queries_via_get=False, + # Strawberry recently changed multipart request handling, which now + # requires enabling support explicitly for views. + # https://github.com/strawberry-graphql/strawberry/issues/3655 + multipart_uploads_enabled=True, ), ) diff --git a/setup.py b/setup.py index 54ec5755..c67a949f 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ "gunicorn>=23.0.0", "imagesize>=1.4.1", "pycocotools>=2.0.8", - "strawberry-graphql>=0.239.2", + "strawberry-graphql>=0.243.0", ], "dev": [ "black==24.2.0",