|
|
%!s(int64=7) %!d(string=hai) anos | |
|---|---|---|
| .. | ||
| main | %!s(int64=7) %!d(string=hai) anos | |
| CMakeLists.txt | %!s(int64=7) %!d(string=hai) anos | |
| Makefile | %!s(int64=7) %!d(string=hai) anos | |
| README.md | %!s(int64=7) %!d(string=hai) anos | |
| partitions_example.csv | %!s(int64=7) %!d(string=hai) anos | |
| sdkconfig.defaults | %!s(int64=7) %!d(string=hai) anos | |
(See the README.md file in the upper level 'examples' directory for more information about examples.)
HTTP file server example demonstrates file serving using the esp_http_server component of ESP-IDF:
/path/filename for GET command downloads the corresponding file (if exists)/upload POST command for uploading the file onto the device/delete POST command for deleting the file from the deviceFile server implementation can be found under main/file_server.c which uses SPIFFS for file storage. main/upload_script.html has some HTML, JavaScript and Ajax content used for file uploading, which is embedded in the flash image and used as it is when generating the home page of the file server.
Configure the project using make menuconfig and goto Example Configuration ->
In order to test the file server demo :
make flashmake monitor and note down the IP assigned to your ESP module. The default port is 80http://192.168.43.130/ or http://192.168.43.130/index.html to see an HTML web page with list of files on the server (initially empty)myfile.html is uploaded to /path/on/device/myfile_copy.html using curl -X POST --data-binary @myfile.html 192.168.43.130:80/upload/path/on/device/myfile_copy.htmlcurl 192.168.43.130:80/path/on/device/myfile_copy.html > myfile_copy.htmlcmp myfile.html myfile_copy.htmlBrowsers often send large header fields when an HTML form is submit. Therefore, for the purpose of this example, HTTPD_MAX_REQ_HDR_LEN has been increased to 1024 in sdkconfig.defaults. User can adjust this value as per their requirement, keeping in mind the memory constraint of the hardware in use.