11/*
22SPIFFSReadServer
3- Ryan Downing
4- version 0.0.4
3+ Created by: Ryan Downing
4+ Updaed by: HA4ever
5+ version 0.0.5
56*/
67
78// just replace "ESP8266WebServer server(80);" declaration with "SPIFFSReadServer server(80);"
89
910#define DEBUG_SPIFFSREADSERVER (x )
1011
1112#include < ESP8266WebServer.h>
12- #include < FS .h>
13+ #include < LittleFS .h>
1314
1415#ifndef SPIFFSREADSERVER_H
1516#define SPIFFSREADSERVER_H
@@ -60,15 +61,15 @@ class SPIFFSReadServer: public ESP8266WebServer {
6061
6162 // look for smaller versions of file
6263 // minified file, good (myscript.min.js)
63- if (SPIFFS .exists (prefix + " .min" + ext)) path = prefix + " .min" + ext;
64+ if (LittleFS .exists (prefix + " .min" + ext)) path = prefix + " .min" + ext;
6465 // gzipped file, better (myscript.js.gz)
65- if (SPIFFS .exists (prefix + ext + " .gz" )) path = prefix + ext + " .gz" ;
66+ if (LittleFS .exists (prefix + ext + " .gz" )) path = prefix + ext + " .gz" ;
6667 // min and gzipped file, best (myscript.min.js.gz)
67- if (SPIFFS .exists (prefix + " .min" + ext + " .gz" )) path = prefix + " .min" + ext + " .gz" ;
68+ if (LittleFS .exists (prefix + " .min" + ext + " .gz" )) path = prefix + " .min" + ext + " .gz" ;
6869
69- if (SPIFFS .exists (path)) {
70+ if (LittleFS .exists (path)) {
7071 DEBUG_SPIFFSREADSERVER (" sending file " + path);
71- File file = SPIFFS .open (path, " r" );
72+ File file = LittleFS .open (path, " r" );
7273 if (ESP8266WebServer::hasArg (" download" ))
7374 ESP8266WebServer::sendHeader (" Content-Disposition" , " attachment;" );
7475 if (ESP8266WebServer::uri ().indexOf (" nocache" ) < 0 )
@@ -84,7 +85,7 @@ class SPIFFSReadServer: public ESP8266WebServer {
8485 }
8586 file.close ();
8687 return true ;
87- } // if SPIFFS .exists
88+ } // if LittleFS .exists
8889 return false ;
8990 } // bool handleFileRead
9091
0 commit comments