|
|
před 6 roky | |
|---|---|---|
| .. | ||
| main | před 6 roky | |
| CMakeLists.txt | před 6 roky | |
| Makefile | před 6 roky | |
| README.md | před 6 roky | |
| partitions_example.csv | před 6 roky | |
| sdkconfig.defaults | před 6 roky | |
(See the README.md file in the upper level 'examples' directory for more information about examples.)
HTTP file server example demonstrates file serving with both upload and download capability, using the esp_http_server component of ESP-IDF. The following URIs are provided by the server:
| URI | Method | Description |
|---|---|---|
index.html |
GET | Redirects to / |
favicon.ico |
GET | Browsers use this path to retrieve page icon which is embedded in flash |
/ |
GET | Responds with webpage displaying list of files on SPIFFS and form for uploading new files |
/<file path> |
GET | For downloading files stored on SPIFFS |
/upload/<file path> |
POST | For uploading files on to SPIFFS. Files are sent as body of HTTP post requests |
/delete/<file path> |
POST | Command for deleting a file from SPIFFS |
File 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.
/index.html and /favicon.ico can be overridden by uploading files with same pathname to SPIFFS.
Open the project configuration menu (idf.py menuconfig) go to Example Configuration ->
In order to test the file server demo :
idf.py -p PORT flashidf.py -p PORT 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.