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

Moderator: igrr

User avatar
By seedseifer
#61849 Hello,

someone have an example for download files (png, txt, bin etc) from http server and store them on SPIFFS?

Cannot find an example for that, only storing html results for simple "get" like the part of code bellow:

while(client.available()) {
line = client.readStringUntil('\r');
line.trim();

thks
User avatar
By Erol444
#78136 I got it working like this :)
Code: Select all    String url = String(UPDATE_URL) + response.substring(4);
    //url = http://123.123.123.123/SPIFFS/test2.htm
    String file_name=response.substring(response.lastIndexOf('/'));
    //file_name = test2.htm
    Serial.println(url);
    File f = SPIFFS.open(file_name, "w");
    if (f) {
      http.begin(url);
      int httpCode = http.GET();
      if (httpCode > 0) {
        if (httpCode == HTTP_CODE_OK) {
          http.writeToStream(&f);
        }
      } else {
        Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
      }
      f.close();
    }
    http.end();