ESPAsyncWebServer icon indicating copy to clipboard operation
ESPAsyncWebServer copied to clipboard

support of SdFat library

Open JoergTiedemann opened this issue 2 years ago • 3 comments

Is there any solution to support hosting files from an sd card using sd_fat library ? in request->send first parameter is fs::FS or File but not FsFile which is used by SdFat Library

JoergTiedemann avatar Feb 19 '24 13:02 JoergTiedemann

Just a "me too". I really need to use SdFat, or at least something more reliable than SD.h. I have added web functions to my project, but I'll have to pull them all out if I can't solve this. Reliable reading and writing of data is more important to my project than the web features.

VeloSteve avatar Mar 14 '24 16:03 VeloSteve

#include "SD.h" #include "FS.h"

server.on("/favicon.ico", HTTP_GET, [](AsyncWebServerRequest *request){ request->send(SD, "/favicon.ico", "image/x-icon"); });

Red-Owl avatar Jun 06 '24 19:06 Red-Owl

#include "SD.h" #include "FS.h"

A solution using SD.h does not help. I get much higher error rates using SD.h.

My current workaround is

  1. For static files I put them in the SPIFFS filesystem before installing the main program and use something like server.serveStatic("/", SPIFFS, "/htdocs/").setCacheControl("max-age=86400");
  2. For files on the SD card, I use request->sendChunked() and call my own function which reads up to 4096 bytes at a time using SdFat.

Of course either half of the workaround could work for all files, but this work for me. It is partly because my static files are mostly small and the only file I normally send from the SD card can be very large.

VeloSteve avatar Sep 12 '24 16:09 VeloSteve