Hello. I try to download binary file and write it to SD card. My code:
WiFiClientSecure clientUpd;
clientUpd.setInsecure();
if (!clientUpd.connect("maketest.it", 443))
Serial.println("Connection failed!");
else {
Serial.println("Connected to server!");
clientUpd.println("GET /file.bin HTTP/1.1");
clientUpd.println("Host: maketest.it");
clientUpd.println("Connection: close");
clientUpd.println();
while (clientUpd.available() == 0);
ext::File newF;
newF = SD.open("tmp/test.bin", FILE_WRITE);
while (clientUpd.connected()) {
String line = clientUpd.readStringUntil('\n');
Serial.println(line);
if (line == "\r") {
Serial.println("headers received");
break;
}
}
while (clientUpd.available()) {
byte c = clientUpd.read();
if (newF) {
newF.write(c);
}
}
newF.close();
clientUpd.stop();
Serial.println("Finished read bytes");
}
It's start downloading and saved to SD-card, but it's download only 16kb (file over 2mb).
Can you what is trouble and how to download all file? Thanks!!