Skip to content

Commit

Permalink
[sam2][demo][1/x] Fix file upload
Browse files Browse the repository at this point in the history
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 [email protected]
```

*Response*

```
{"data": {"uploadVideo": {"path": "uploads/<HASH>.mp4"}}}
```
  • Loading branch information
raedle committed Oct 8, 2024
1 parent 29267c8 commit 0d7a428
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions demo/backend/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
)

Expand Down

0 comments on commit 0d7a428

Please sign in to comment.