WebDAV get file
This commit is contained in:
parent
c7137f74a1
commit
f3f378a54a
|
@ -117,13 +117,29 @@ 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);
|
||||
httpd_resp_send(req, webdavBuffer, bytesWritten);
|
||||
break;
|
||||
}
|
||||
case HTTP_DELETE:
|
||||
case HTTP_DELETE:
|
||||
{
|
||||
httpd_resp_set_hdr(req, "Content-Type", "text/plain");
|
||||
|
||||
|
|
Loading…
Reference in New Issue