Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Artur Gaspar
#24535 I am building an interface using JQuery , I could make everything work perfectly, but I have a speed problem.
When you send an image or a file that is not HTML I am using the routine below.
Works but believe she is to blame for the low speed.
Any ideas on how to improve ?

Code: Select all  String arq;

  if (dataType == "text/html") {
    while (dataFile.available()) {
      arq += char(dataFile.read());
    }
    server.send(200, dataType, arq);
  } else {
    char a[500];
    WiFiClient client = server.client();
    while (dataFile.available()) {
      for (int i = 0; i < 500; i++) {
        a[i] = dataFile.read();
      }
      client.write(&a[0], 500);
    }
  }
User avatar
By SwiCago
#24665 There is a method called "streamFile"
just like server.sendContent or sendHeader

Usage is: template<typename T> size_t streamFile(T &file, String contentType)
Exxample usage:
Code: Select allif(server.streamFile(dataFile,"image/jpeg") != dataFile.size()) {
  Serial.printLn("Did not stream entire file, maybe file path not correct!");
}


Here is a full sample(not mine) in git on how it is used. You'll be able to pull the bits you need and get it to work (Read/Write files to SD card via webserver)
https://github.com/esp8266/Arduino/blob ... Server.ino