Closed PaulFreund closed 6 years ago
I have written a routine that uploads ota updates to MicroSD (unfortunately proprietary) via HTTP POST. In this scenario I have to detect where in the HTTP body the binary data starts after the multipart boundary and where it ends with one. In the post buffer the value of the boundary field is used with two prepended hyphens:
----WebKitFormBoundarywrAqgDbLLFmgN4Zn
becomes
------WebKitFormBoundarywrAqgDbLLFmgN4Zn
This is also what the original code did, in the buffer was:
boundary=----WebKitFormBoundarywrAqgDbLLFmgN4Zn
and after replacing the buffer was:
boundar------WebKitFormBoundarywrAqgDbLLFmgN4Zn
and then the multipartBoundary pointer was set to position 7 which is
------WebKitFormBoundarywrAqgDbLLFmgN4Zn
Now after that commit the user will find ----WebKitFormBoundarywrAqgDbLLFmgN4Zn in the buffer and has to add the two hyphens himself when searching for it in POST data. I don't know if this is in the scope of this library. If it should be we need to add an upload function.
@PaulFreund ahh that makes it a little bit clearer.
Let me merge this in as its an improvement, thanks for the PR!
@PaulFreund would you please add your implementation of searching for the file data start/stop in a multipart/form-data to the improved vfs upload function? (I've improved and tested the old one. I'm working on a PR, but would be great to handle POSTed form files as well.)
We also need to find the value of the "filename" parameter in the form. I left a todo here for that: https://github.com/phatpaul/libesphttpd/blob/vfs_upload/util/esp32_httpd_vfs.c#L355
Sorry for double-post. My comments seem to disappear after I post them.
This commit fixes #38