| 677 | } |
| 678 | |
| 679 | esp_err_t editfileHandler(httpd_req_t *req) { |
| 680 | if (!checkUserWebAuth(req)) return ESP_OK; |
| 681 | String fileName = queryValue(req, "name"); |
| 682 | if (fileName.isEmpty()) { |
| 683 | sendText(req, 400, "text/plain", "Missing name"); |
| 684 | return ESP_OK; |
| 685 | } |
| 686 | |
| 687 | if (req->method == HTTP_GET) { |
| 688 | File file = SDM.open(fileName); |
| 689 | if (!file) { |
| 690 | sendText(req, 404, "text/plain", "Not found"); |
| 691 | return ESP_OK; |
| 692 | } |
| 693 | httpd_resp_set_type(req, "text/plain"); |
| 694 | httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); |
| 695 | while (file.available()) { |
| 696 | size_t len = file.read(buff, bufSize); |
| 697 | httpd_resp_send_chunk(req, reinterpret_cast<const char *>(buff), len); |
| 698 | } |
| 699 | httpd_resp_send_chunk(req, nullptr, 0); |
| 700 | file.close(); |
| 701 | } else { |
| 702 | String body; |
| 703 | if (!receiveBody(req, body, 32768)) { |
| 704 | sendText(req, 400, "text/plain", "Too large"); |
| 705 | return ESP_OK; |
| 706 | } |
| 707 | File file = SDM.open(fileName, "w"); |
| 708 | if (!file) { |
| 709 | sendText(req, "text/plain", "FAIL"); |
| 710 | return ESP_OK; |
| 711 | } |
| 712 | file.print(body); |
| 713 | file.close(); |
| 714 | sendText(req, "text/plain", "OK"); |
| 715 | } |
| 716 | return ESP_OK; |
| 717 | } |
| 718 | |
| 719 | esp_err_t nvsHandler(httpd_req_t *req) { |
| 720 | if (!checkUserWebAuth(req)) return ESP_OK; |
nothing calls this directly
no test coverage detected