-->
Page 1 of 1

sending larger size files by no of packets in wifi server

PostPosted: Tue Jul 21, 2015 8:16 pm
by kathir
Thanking to all who made ESP8266 PLUGIN for Arduino IDE Can any one guide me how to send large filesto client by spiliting in to no of small packets in ESP8266 WIFI WEBSERVER using Ardunio IDE


M.KATHIRESAN

Re: sending larger size files by no of packets in wifi serve

PostPosted: Wed Jul 29, 2015 4:48 am
by SwiCago
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 allFile dataFile = SD.open("/path/file");
if(server.streamFile(dataFile,"image/jpeg") != dataFile.size()) {
  Serial.printLn("Did not stream entire file, maybe file path not correct!");
}
dataFile.close(),


Tip: Create your webpage HTML in a way that does not make multiple file requests at once. For example, a webpage with multiple image tags, the browser will try to download more than one at one time. This will overload the ESP and it will crash. Small files, such as html,js,css are ok, but large files such as images not so. Instead, spread the load by loading one file at a time.
I used simple onload js method to load one pic at a time in a gallery. This allowed one pic to load and as soon as it was downloaded, the next one would get picked up and so on. This worked well for me.

Here is a full webserver 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