Feature/http multipart post (file upload to sming webserver) #690
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the first "fully" working implementaiton for file-uploading/http-multipart-post for http server. (#552)
Currently it provides functionality to:
To enable uploading for a certain path, a delegate has to be provided:
void addPath(String path, HttpPathDelegate callback, HttpUploadDelegate uploadcallback);
The uploadcallback function is defined as following:
The function has thus access to the current request in the sense of all Header and Query Paramters (as well as path) can be accessed to decide if we accept the upload (or not)
In the pathdelegate information about the uploaded files is accessible by calling:
HttpUpload is defined as
after a successfull upload
curSize
andbufferdata
will be NULL and not accessible anymore (to avoid tampering with ittype
contains the content-type field valuesname
is the variable name defined in the form fieldIf we receive a http-multipart-request without a filename or if the filename is empty - the data will be treated as normal http-post parameters and is accessible via
getPostParameter
- the limitNETWORK_MAX_HTTP_PARSING_LEN
applies to all data that is not a file.For testing see the working examples in
samples/HttpServer_Upload
Please test it thoroughly and provide feedback. If you encounter any issues, it would be great if you document what has lead to the issue and provide a debug log.
Do you have any suggestion/remarks?
Known limitations/issues:
(it seems that chrome sends the header again when one presses go-back to the fileupload page)
how should we handle this use case? how to inform the user - automatically or should the "user of the framework" take care of this in the callback?