»File Upload

Strawberry supports multipart uploads as described here: https://github.com/jaydenseric/graphql-multipart-request-spec for ASGI and Django.

Uploads can be used in mutations via the Upload type.

»ASGI

Since ASGI uses asyncio for communication the resolver must be async as well.

Example:

from strawberry.file_uploads import Upload
...
@strawberry.type
class Mutation:
    @strawberry.mutation
    async def read_text(self, text_file: Upload) -> str:
        file_contents = await text_file.read()
        # do something awesome
        return "a string"

»Flask

Example:

import strawberry
from strawberry.file_uploads import Upload


@strawberry.type
class Mutation:
    @strawberry.mutation
    def read_text(self, text_file: Upload) -> str:
        return text_file.read().decode()


»Django

Documentation coming soon

Edit on Github

Newsletter 💌

Do you want to receive the latest updates on Strawberry? Subscribe to our newsletter!