diff --git a/firmware/lib/esphttp/WebDAV.cpp b/firmware/lib/esphttp/WebDAV.cpp index cfeac21..b801516 100644 --- a/firmware/lib/esphttp/WebDAV.cpp +++ b/firmware/lib/esphttp/WebDAV.cpp @@ -117,13 +117,29 @@ std::function webdavHandler(const char *uriPrefix, switch (req->method) { case HTTP_GET: + { + auto filename = uriToFileName(uri, spiffsFolder); + Serial.printf("GET filename %s\n", filename.c_str()); + auto file = portablefs::open(filename.c_str(), "r"); + if (file.available()) + { + uint8_t *buffer = (uint8_t *)heap_caps_malloc(file.size(), MALLOC_CAP_SPIRAM); + file.read(buffer, file.size()); + httpd_resp_set_hdr(req, "Content-Type", "application/x-msgpack"); + httpd_resp_send(req, (char *)buffer, file.size()); + free(buffer); + } + else + httpd_resp_send_404(req); + break; + } case HTTP_PROPFIND: { size_t bytesWritten = webdavFileListingSpiffs(webdavBuffer, WEBDAV_BUFF_LEN, spiffsFolder); httpd_resp_send(req, webdavBuffer, bytesWritten); break; } - case HTTP_DELETE: + case HTTP_DELETE: { httpd_resp_set_hdr(req, "Content-Type", "text/plain");