rawhat / mist

gleam HTTP server. because it glistens on a web
Apache License 2.0
333 stars 12 forks source link

Question: how to get `FileBody` out of request? #22

Closed tupini07 closed 1 year ago

tupini07 commented 1 year ago

I have a small server that allows anyone to POST an image so that this is saved to the disk of the server.

I can use mist to easily get the bitstring representation of the image in the request's body, and in theory I could parse this to extract the various metadata attributes about the file (e.g. filename, content-type, etc), as well as the actual bytes of the image.

But I was wondering if there is already a built-in way to do this, or you can think of an easier way than parsing the request body manually 🤗 thanks!

rawhat commented 1 year ago

Do you mean the FileBody exported from mist? If so, that is just used to determine how to handle returning that data in the response. I'm not sure of the exact process for handling the image upload here, but I imagine you want to just handle the bytes as you mentioned. The library doesn't have anything built-in for things like this.

Hope that helps! Let me know if I'm misunderstanding the question.

tupini07 commented 1 year ago

ohh I see yes that answers my question thanks!

I'll see if I manage to write a parser by hand :) If I do get it working I'll see about contributing it back

In the meantime, I'll close this issue. Thanks again!