Page 1 of 1

read file on SD with big size

Posted: Tue Aug 27, 2019 11:43 am
by mehrdadco
hi
I have a question, maybe someone can help me
I store outputs of several different sensors on one file in SD.
After a day, the file reaches a maximum of about 4 MB in size
I wanted to send this file to my server from the internet (with post.request or FTP client or ... )
My problem is when I want to read this file from SD
file.readstring();
It cannot handle all data on a file and can only hold up to 63kg
at first, I thought that it's on limitation on sending data which that can not send the whole file but after making a file again that I just read I found out that its reading string problem
String cer = fie.readString();
File file = SD.open("/temp.txt");
if (!file) {
writeFile(SD, "/temp.txt", cer.c_str());
}
else {
Serial.println("File already exists");
}
file.close();
What do you think I can do or what way should i use to read a full size of a file?
and if there is a better way to send a file with this size?

Re: read file on SD with big size

Posted: Tue Aug 27, 2019 9:40 pm
by MaxVapor
You have a limited amount of memory to work with so you cannot load the whole file into a string, you need to read the file in chunks and upload to the server.

See an example from the SDK here:
https://github.com/espressif/esp-idf/bl ... e_server.c

Re: read file on SD with big size

Posted: Thu Aug 29, 2019 9:05 am
by mehrdadco
that shows me the way THANK YOU