Home » U++ Library support » U++ Core » multipart/form-data parsing with multi file upload support
|multipart/form-data parsing with multi file upload support [message #36968]
||Wed, 01 August 2012 14:09
Registered: August 2007
Location: Russia, Moscow rgn.
Recently I've made a helper function which parses multipart/form-data. Field entries are added to output VectorMap and attached files are saved directly to disk. The main idea was to avoid large memory requirements even for big uploaded files due to streaming (which is critical for web servers).|
The function supports multi file upload (multipart/mixed) data.
const String &contentType,
const String &dir,
const int maxFileSize = 100*1024*1024
contentType is the string from http headers ("Content-type: ...").
dir - directory to save files to.
isFieldsListOnly - is an option to get only those fields and files which are needed (you add them to fields and files list prior to function call).
The output is fields and files maps, where fields filled with field values and files are filled with filenames.
I did not have a chance to test it thoroughly (but it successfully passed a number of test examples), so I'd be glad if anyone give me any feedback on it.
The test source with function and small example is included. Hope this helps someone.
UPDATE: test data file added.
[Updated on: Wed, 01 August 2012 22:18]
Report message to a moderator
Current Time: Mon Sep 27 00:51:17 CEST 2021
Total time taken to generate the page: 0.02049 seconds