Need help with downloading files and saving them to SPIFFS
Posted: Fri Feb 02, 2018 4:45 am
Hello everyone.
I'm trying to get ESP8266 to download a bunch of files from a server and to save them to SPIFFS, but I'm having a hard time making it happen.
I can get a file from a server and load it to a string variable using this:
and then i can save the string to a file using something like that:
It works just fine with small text files, but it crashes with larger files.
Can someone help me with this one?
I'm trying to get ESP8266 to download a bunch of files from a server and to save them to SPIFFS, but I'm having a hard time making it happen.
I can get a file from a server and load it to a string variable using this:
Code: Select all
String url = "http://domain.com/file.whatever";
HTTPClient http;
http.begin(url);
String payload = http.getString();
http.end();
and then i can save the string to a file using something like that:
Code: Select all
void stringToFile(String fileName, String text) {
File f = SPIFFS.open(fileName, "w");
f.write((uint8_t *)text.c_str(), text.length());
f.close();
}
It works just fine with small text files, but it crashes with larger files.
Can someone help me with this one?