I'm reading a file and uploading it to a webserver on the local network over Wifi. BUt it's is extremely slow. About 6 seconds (!) for a 11KB file. This makes uploading photos almost impossible. That can't be right?
Anyone have any tips on how to speed things up?
File file = SD.open("/outbox/001/me2.jpg", FILE_READ);
if (!file) {
Serial.println("booboo");
return;
}
String size = String(file.size());
Serial.println("filesize " + size);
Serial.print("connecting to ");
Serial.println(host);
// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 4000;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
// We now create a URI for the request
String url = "/upload";
Serial.print("Requesting URL: ");
Serial.println(url);
// This will send the request to the server
client.print(String("POST ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n");
client.print("Content-Length: ");
client.println(size);
client.println("");
Serial.println("start sending");
while (file.available()){
client.write(file.read());
}
Serial.println("end sending");
file.close();
client.println("");
Serial.println();
Serial.println("closing connection");
client.stop();
delay(2000);
SD.end();
Please note I'm using an ESP32 dev board. This has a built in SD socket.