# Upload file mutation

**URL:** <https://discuss.dgraph.io/t/upload-file-mutation/10312>\
**Category:** GraphQL\
**Tags:** kind:question\
**Created:** [September 12, 2020, 11:06am UTC](https://discuss.dgraph.io/t/upload-file-mutation/10312 "2020-09-12T11:06:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aleclofabbro](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/aleclofabbro/32/4500_2.png) [@aleclofabbro](https://discuss.dgraph.io/u/aleclofabbro)\
**Post date:** [September 12, 2020, 11:06am UTC](https://discuss.dgraph.io/t/upload-file-mutation/10312/1 "2020-09-12T11:06:31Z")

</div>

Any hint or pattern for handling mutations with some binary data arguments to be stored as files ?

---

<div class="post-metadata">

**Author:** ![JatinDevDG](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jatindevdg/32/3417_2.png) [@JatinDevDG](https://discuss.dgraph.io/u/JatinDevDG)\
**Post date:** [September 14, 2020, 12:21pm UTC](https://discuss.dgraph.io/t/upload-file-mutation/10312/3 "2020-09-14T12:21:49Z")

</div>

Hi @aleclofabbro, currently we don’t support storing data as a file in Dgraph but we will surely discuss it internally. Thanks for reaching out to us.

---

<div class="post-metadata">

**Author:** ![aleclofabbro](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/aleclofabbro/32/4500_2.png) [@aleclofabbro](https://discuss.dgraph.io/u/aleclofabbro)\
**Post date:** [September 14, 2020, 1:10pm UTC](https://discuss.dgraph.io/t/upload-file-mutation/10312/4 "2020-09-14T13:10:28Z")

</div>

thanks @JatinDevDG,  
I was thinking of a custom resolver that could manage uploaded file and execute proper graphql (e.g. storing file-url)  
but I wonder how should I define schema for receiving binary over GraphQL

---

<div class="post-metadata">

**Author:** ![JatinDevDG](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jatindevdg/32/3417_2.png) [@JatinDevDG](https://discuss.dgraph.io/u/JatinDevDG)\
**Post date:** [September 14, 2020, 4:13pm UTC](https://discuss.dgraph.io/t/upload-file-mutation/10312/5 "2020-09-14T16:13:33Z")

</div>

Currently we don’t have support for storing files or a byte datatype. You can try to use String datatype if that works in your use case.

---

<div class="post-metadata">

**Author:** ![abhimanyusinghgaur](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/abhimanyusinghgaur/32/2980_2.png) [@abhimanyusinghgaur](https://discuss.dgraph.io/u/abhimanyusinghgaur)\
**Post date:** [September 14, 2020, 4:56pm UTC](https://discuss.dgraph.io/t/upload-file-mutation/10312/6 "2020-09-14T16:56:00Z")

</div>

> [@aleclofabbro](#):
>
> but I wonder how should I define schema for receiving binary over GraphQL

The official GraphQL spec doesn’t define any type which can contain binary data. All the transport happens over HTTP in JSON. And, even in JSON there is no way that you can put binary data unless you want to put the byte string as a `String` in JSON. But, that would probably not be the best deal you might want, because that would be worse than using the decoded file contents as `String`. JSON has got UTF-8 character encoding support, so I think the best you can achieve ATM with this is to decode the file contents as a `String` and send it over as a parameter to some GraphQL query. That way you would be able to use `String` type in GraphQL to represent the file data. You can probably store the file type too along with the data on the GraphQL server.

But, then where do you want to store those files also decides how you should approach this problem. I see that you want to just store the file URL in Dgraph, and not the file contents itself. So, why not create a separate HTTP endpoint which can handle file upload, and then that endpoint internally makes a call to the GraphQL API to store the file URL once the file has been uploaded on that server.
