This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Binary file upload to http server

Part Number: CC3220SF-LAUNCHXL

Hello

Im looking for a way to upload binary file update for a device connected to the wifi board. Details of the problem bellow:

Im am running the http server ported via the portable example, as in the simplelink academy. Temp readouts and LED control works. Uart display has been disabled and uart is converted to other uses.

I have registered the URL at number 3 for the request as /update,and given it characteristic of "file.name" and "file", which are also my form members, at the appropriate places in the initHttpserverDB() function.
The form with the contents of file.name=filename and file=filecontent is sent properly using ajax with the url="/update", data=formdata and enctype= "multipart/form-data". I have raised the number of URI services to 4.

Due to the nature of the binary file(not necessarily ascii data), "application/x-www-form-urlencoded" is not a valid enctype, as far as i know "multipart/form-data" must be used.
The server enters the postHandler, then httpCheckContentInDB, parsing metadata returns 0(no error). parseUrlEncoded returns -1. As far as i can tell this is because of the enctype used (multipart/form-data does not necessarily use "&" to seperate the characterictic-value array.)This means my callback registered in DB for /update will not be entered.

At the point of faliure i can see my form in the pPhrase variable in parseUrlEncoded 

The browser console shows the following:
"XML Parsing Error: no element found
Location: http://mysimplelink.net/update
"

My first question is, am I doing something wrong? Have i missed something obvious that would make this work as is?

My main question is, if i have to create a new handler for  multipart/form-data enctype, what would be the propper/efficient way to do it? Should i simply redirect it from the existing one based on requestIdx? Is there a different way, without breaking anything?

  • Please refer to the out_of_the_box example in the SDK.

    The file "link_lock_task.c" implements the http server in a similar way instructed in the Simplelink Academy. 

    This one also supports receiving an OTA update image (see httpRequest[1]), but through the HTTP PUT request.

    The "local OTA" example (available in SDKs up to 5.30) or the mqtt_clinet with OTA support in (SDK 6.10) that uses a simplified HTTP Server interface are also good references for receiving a binary content from a web browser.