# Handling multipart/form-data with Mux or HTTP

**URL:** <https://discourse.julialang.org/t/handling-multipart-form-data-with-mux-or-http/24918>\
**Category:** General Usage\
**Tags:** mux\
**Created:** [June 4, 2019, 2:42pm UTC](https://discourse.julialang.org/t/handling-multipart-form-data-with-mux-or-http/24918 "2019-06-04T14:42:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tencnivel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tencnivel/32/8662_2.png) [@tencnivel](https://discourse.julialang.org/u/tencnivel)\
**Post date:** [June 4, 2019, 2:42pm UTC](https://discourse.julialang.org/t/handling-multipart-form-data-with-mux-or-http/24918/1 "2019-06-04T14:42:33Z")

</div>

Hi everyone! I’m trying to handle the upload of files (several files at the same time) using Mux.

I would like to be able to loop over the input parts and for each of them :

1. get the name of the file
2. get the content of the file

With Mux, in req[:data] there’s a Vector{UInt8}. That’s pretty much where I am now 😅.

In [this post](https://discourse.julialang.org/t/http-multipart-form-data-processing-by-server/24076)@rssdev10 gives a function that can extract the content of a file from a Vector{UInt8}.  
It works from a Vector{UInt8} previously serialized (using `serialize()`) but doesn’t work (oddly enough) on applied to req[:data] in the `route()` function, which is the normal scenario. It also doesn’t extract the filename.

Has anyone succeeded in handling multipart/form-data with Mux or HTTP?

---

<div class="post-metadata">

**Author:** ![rssdev10](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@rssdev10](https://discourse.julialang.org/u/rssdev10)\
**Post date:** [June 5, 2019, 7:32am UTC](https://discourse.julialang.org/t/handling-multipart-form-data-with-mux-or-http/24918/2 "2019-06-05T07:32:05Z")

</div>

Hi, I believe that multipart data processing should be a part of HTTP.jl. Actually I have prepared simple code sample for parsing HTTP.jl data but not ready to dive into full development of that library. It would be good to have some comments from key developers…

And regarding web app with file uploading see [https://github.com/rssdev10/JWebImageDemo.jl/blob/master/src/run.jl](https://github.com/rssdev10/JWebImageDemo.jl/blob/master/src/run.jl)

---

<div class="post-metadata">

**Author:** ![tencnivel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tencnivel/32/8662_2.png) [@tencnivel](https://discourse.julialang.org/u/tencnivel)\
**Post date:** [July 29, 2019, 5:43am UTC](https://discourse.julialang.org/t/handling-multipart-form-data-with-mux-or-http/24918/3 "2019-07-29T05:43:57Z")

</div>

The code from @rssdev10 in [this post](https://discourse.julialang.org/t/http-multipart-form-data-processing-by-server/24076/2) actually works fine (for uploading one file).

If using Mux, the code is then the following:

```julia
file_content = parse_multipart(req[:data])
write("test.png",file_content)

```

With `parse_multipart` being given in the post aforementioned

---

<div class="post-metadata">

**Author:** ![tencnivel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tencnivel/32/8662_2.png) [@tencnivel](https://discourse.julialang.org/u/tencnivel)\
**Post date:** [August 4, 2019, 1:48pm UTC](https://discourse.julialang.org/t/handling-multipart-form-data-with-mux-or-http/24918/4 "2019-08-04T13:48:21Z")

</div>

There is a better solution that can handle several files,  
[here](https://discourse.julialang.org/t/http-multipart-form-data-processing-by-server/24076/6)
