| 645 | } |
| 646 | |
| 647 | esp_err_t fileHandler(httpd_req_t *req) { |
| 648 | if (!checkUserWebAuth(req)) return ESP_OK; |
| 649 | String fileName = queryValue(req, "name"); |
| 650 | String fileAction = queryValue(req, "action"); |
| 651 | if (fileName.isEmpty() || fileAction.isEmpty()) { |
| 652 | sendText(req, 400, "text/plain", "ERROR: name and action params required"); |
| 653 | return ESP_OK; |
| 654 | } |
| 655 | |
| 656 | if (!SDM.exists(fileName)) { |
| 657 | if (fileAction == "create") { |
| 658 | if (!SDM.mkdir(fileName)) sendText(req, "text/plain", "FAIL creating folder: " + fileName); |
| 659 | else sendText(req, "text/plain", "Created new folder: " + fileName); |
| 660 | } else { |
| 661 | sendText(req, 400, "text/plain", "ERROR: file does not exist"); |
| 662 | } |
| 663 | return ESP_OK; |
| 664 | } |
| 665 | |
| 666 | if (fileAction == "download") sendFileDownload(req, fileName); |
| 667 | else if (fileAction == "delete") { |
| 668 | if (deleteFromSd(fileName)) sendText(req, "text/plain", "Deleted : " + fileName); |
| 669 | else sendText(req, "text/plain", "FAIL delating: " + fileName); |
| 670 | } else if (fileAction == "create") { |
| 671 | if (!SDM.mkdir(fileName)) sendText(req, "text/plain", "FAIL creating existing folder: " + fileName); |
| 672 | else sendText(req, "text/plain", "Created new folder: " + fileName); |
| 673 | } else { |
| 674 | sendText(req, 400, "text/plain", "ERROR: invalid action param supplied"); |
| 675 | } |
| 676 | return ESP_OK; |
| 677 | } |
| 678 | |
| 679 | esp_err_t editfileHandler(httpd_req_t *req) { |
| 680 | if (!checkUserWebAuth(req)) return ESP_OK; |
nothing calls this directly
no test coverage detected