I have no idea how you're meant to go about parsing a multipart form besides doing it manually using just the raw post-data string as input
I will try to adjust the Hyper example but any help will be much appreciated.
Relevant issues:
I have no idea how you're meant to go about parsing a multipart form besides doing it manually using just the raw post-data string as input
I will try to adjust the Hyper example but any help will be much appreciated.
Relevant issues:
Rocket's primary abstraction for data is the
FromData
trait. Given the POST data and the request, you can construct a given type:Then, it's just a matter of reading the API for multipart and inserting tab A into slot B:
I've never used either of these APIs before about an hour ago, so there's no guarantee that this is a good implementation. In fact, all the panicking on error definitely means it's suboptimal. A production usage would handle all of those cleanly.
However, it does work:
An advanced implementation would allow for some abstraction between the user-specific data and the generic multipart aspects. Something like
Multipart<MyForm>
would be nice.The author of Rocket points out that this solution allows a malicious end user to POST an infinitely sized file, which would cause the machine to run out of memory. Depending on the intended use, you may wish to establish some kind of cap on the number of bytes read, potentially writing to the filesystem at some breakpoint.