me-no-dev / ESPAsyncWebServer

Async Web Server for ESP8266 and ESP32
3.77k stars 1.22k forks source link

support of SdFat library #1379

Open JoergTiedemann opened 8 months ago

JoergTiedemann commented 8 months ago

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

VeloSteve commented 8 months ago

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.

Red-Owl commented 5 months ago

include "SD.h"

include "FS.h"

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

VeloSteve commented 2 months ago

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.