Skip to content

Commit 716eafe

Browse files
ficetoficeto
ficeto
authored and
ficeto
committed
Revert "Revert "Edit SD Server example to use the new Write(Stream) method""
This reverts commit 163a983.
1 parent de9873d commit 716eafe

File tree

1 file changed

+2
-15
lines changed
  • hardware/esp8266com/esp8266/libraries/ESP8266WebServer/examples/SDWebServer

1 file changed

+2
-15
lines changed

hardware/esp8266com/esp8266/libraries/ESP8266WebServer/examples/SDWebServer/SDWebServer.ino

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,10 @@ bool loadFromSdCard(String path){
111111
dataType = 0;
112112
path = 0;
113113

114-
uint8_t obuf[WWW_BUF_SIZE];
115-
116-
while (dataFile.available() > WWW_BUF_SIZE){
117-
dataFile.read(obuf, WWW_BUF_SIZE);
118-
if(client.write(obuf, WWW_BUF_SIZE) != WWW_BUF_SIZE){
119-
DBG_OUTPUT_PORT.println("Sent less data than expected!");
120-
dataFile.close();
121-
return true;
122-
}
123-
}
124-
uint16_t leftLen = dataFile.available();
125-
dataFile.read(obuf, leftLen);
126-
if(client.write(obuf, leftLen) != leftLen){
114+
if(client.write(dataFile) != dataFile.size()){
127115
DBG_OUTPUT_PORT.println("Sent less data than expected!");
128-
dataFile.close();
129-
return true;
130116
}
117+
131118
dataFile.close();
132119
client.stop();
133120
return true;

0 commit comments

Comments
 (0)