Hi everyone,
I have a ESP32 board and I'm trying to store data to a SPIFFS file.
This is how I'm doing:
bool success = SPIFFS.begin();
if(success){
Serial.println("SPIFFS system mounted with success");
}else{
Serial.println("Error mounting the SPIFFS system");
return;
}
file = SPIFFS.open("image.jpg", FILE_WRITE);
Serial.println("Saving file...");
for (int i = 0; i < rxValues.length(); i++){
file.write(rxValues[i]);
Serial.print(rxValues[i]);
}
Serial.println("");
file.close();
Serial.println("Closed file");
After execution I see this in the console:
16:58:52.312 -> Saving file...
16:58:52.312 -> ⸮⸮⸮⸮JFIF⸮⸮(ICC_PROFILE0mntrRGB XYZ acsp⸮⸮⸮- desc⸮trXYZdgXYZxbXYZ⸮rTRC⸮(gTRC⸮(bTRC⸮(wtpt⸮cp
...
16:58:52.833 -> Closed media file
However, when I reboot my board even though it can find the file created, it says it has 0 bytes:
16:59:12.041 -> SPIFFS system mounted with success
16:59:12.076 -> Listing all files
16:59:12.144 -> FILE: /image.jpg **size: 0**
This is the code I'm using to list all files:
void listAllFiles(){
Serial.println("Listing all files");
File root = SPIFFS.open("/", FILE_READ);
File file = root.openNextFile(FILE_READ);
while(file){
Serial.print("FILE: ");
Serial.print(file.name());
Serial.print(" size: ");
Serial.println(file.size());
file = root.openNextFile(FILE_READ);
}
root.close();
}
I don't know what is wrong here but because I'm assuming the file has been written correctly.
Any tips? Is there a way for me to peek into the content of my Flash RAM and open a file?
Thanks!