read file from SPIFFS return null
Posted: Sat Dec 17, 2022 8:51 am
hello, i am trying to read a file from the spiffs image i have builìt and uploaded to esp.
Whatever file i try to open, when i read it i get null.
this code produces the following log:
i have generated the image with mkspiffs. i also have tryed recompiling mkspiffs with SPIFFS_USE_MAGIC_LENGTH: 4 instead of 1 but nothing changes.
Any ideas??
Whatever file i try to open, when i read it i get null.
Code: Select all
struct stat st;
stat("/spiffs/index.html", &st);
ESP_LOGI(TAG, "index.html size is %ld", st.st_size);
ESP_LOGI(TAG, "Reading file");
FILE* f = fopen("/spiffs/index.html", "r");
char line[32];
fgets(line, sizeof(line), f);
ESP_LOGI(TAG, "Read from file: '%s'", line);
fclose(f);
this code produces the following log:
Code: Select all
I (435) wifi softAP: index.html size is 546
I (437) wifi softAP: Reading file
I (444) wifi softAP: Read from file: ''
i have generated the image with mkspiffs. i also have tryed recompiling mkspiffs with SPIFFS_USE_MAGIC_LENGTH: 4 instead of 1 but nothing changes.
Any ideas??