I've been searching for a way to upload a file (eg. images) using Hot Chocolate and I don't seem to find anything about it in their Docs.
Does anyone know how to do it?
Thanks in advance
I've been searching for a way to upload a file (eg. images) using Hot Chocolate and I don't seem to find anything about it in their Docs.
Does anyone know how to do it?
Thanks in advance
From the Hotchocolate slack channel here is the answer to that question:
unofficially there is this https://gist.github.com/PascalSenn/9b623a439426fa361552632d8bd7972a
and also you can use this:
if they're small files, you can use base64-encoded strings, but that obviously has some limitations
Those are the answers that from my opinion fit best to your question.
Here is the link to the conversation in slack: https://hotchocolategraphql.slack.com/archives/CD9TNKT8T/p1597299757043300
NOTE: you have to subscribe first to see the thread
HotChocolate now supports the Multipart Request Specification for uploading files.
Though, depending on your traffic and frequency of file uploads, you might want to offload file uploads to an external service. With Azure for example you could have a requestUpload resolver that gets a SAS token for Azure Blob Storage and then return this URL to your client. The client can then use this URL to perform the upload.