mirror of
https://github.com/wled/WLED.git
synced 2025-07-21 01:36:32 +00:00
handleFileRead: Leverage AWS code
No need to filter or look up content type, just pitch it over the wall. Also fixes .gz'd content processing.
This commit is contained in:
parent
323c70dcdf
commit
0593a078c6
@ -421,25 +421,19 @@ bool handleFileRead(AsyncWebServerRequest* request, String path){
|
|||||||
DEBUG_PRINT(F("WS FileRead: ")); DEBUG_PRINTLN(path);
|
DEBUG_PRINT(F("WS FileRead: ")); DEBUG_PRINTLN(path);
|
||||||
if(path.endsWith("/")) path += "index.htm";
|
if(path.endsWith("/")) path += "index.htm";
|
||||||
if(path.indexOf(F("sec")) > -1) return false;
|
if(path.indexOf(F("sec")) > -1) return false;
|
||||||
String contentType = request->hasArg(F("download")) ? F("application/octet-stream") : contentTypeFor(path);
|
|
||||||
/*String pathWithGz = path + ".gz";
|
|
||||||
if(WLED_FS.exists(pathWithGz)){
|
|
||||||
request->send(WLED_FS, pathWithGz, contentType);
|
|
||||||
return true;
|
|
||||||
}*/
|
|
||||||
#if defined(BOARD_HAS_PSRAM) && defined(WLED_USE_PSRAM)
|
#if defined(BOARD_HAS_PSRAM) && defined(WLED_USE_PSRAM)
|
||||||
if (path.endsWith(FPSTR(getPresetsFileName()))) {
|
if (path.endsWith(FPSTR(getPresetsFileName()))) {
|
||||||
size_t psize;
|
size_t psize;
|
||||||
const uint8_t *presets = getPresetCache(psize);
|
const uint8_t *presets = getPresetCache(psize);
|
||||||
if (presets) {
|
if (presets) {
|
||||||
AsyncWebServerResponse *response = request->beginResponse_P(200, contentType, presets, psize);
|
AsyncWebServerResponse *response = request->beginResponse_P(200, FPSTR(CONTENT_TYPE_JSON), presets, psize);
|
||||||
request->send(response);
|
request->send(response);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(WLED_FS.exists(path)) {
|
if(WLED_FS.exists(path) || WLED_FS.exists(path + ".gz")) {
|
||||||
request->send(WLED_FS, path, contentType);
|
request->send(WLED_FS, path, String(), request->hasArg(F("download")));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user