WebDAV get file

This commit is contained in:
Martin Bauer 2020-06-21 13:23:52 +02:00
parent c7137f74a1
commit f3f378a54a
1 changed files with 17 additions and 1 deletions

View File

@ -117,6 +117,22 @@ std::function<void(httpd_req_t *)> 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);