Files created by SPIFFS commands are not visible in FBrowser
Posted: Mon Apr 03, 2023 8:34 am
I am learning ESP8266 and SPIFFS file system. There is a plugin that allows you to upload files to a flash format formatted in this file system. And there is a FSBrowser sketch that allows you to view and download flash files in the browser. It works well. When I create a file in a sketch using commands, and then in the same sketch I check what is on the flash, the file I created is visible in the list. But when I upload the sketch with FSBrowser again, this file is not visible. If I upload a sketch with checking which files are on the flash, then the file is visible and all files that are uploaded using FSBrowser or using the plugin are visible. I create a file like this:
I check for the existence of files like this:
Can someone tell me why when using FSBrowser files that are created using commands are not visible? And how to make these files visible?
Code: Select all
if(!SPIFFS.exists(path1+"edit/Test2.txt")){
// Create a file
File file = SPIFFS.open(path1+"edit/Test2.txt", "w+");
// Check if the file has been created and if it is possible to write information to it
if(!file){
Serial.println("Can't open file for writing");
SPIFFS.end();
return;
}
else {
file.write("Hellow, world\n");
file.close();
}
}
I check for the existence of files like this:
Code: Select all
void main_scan(String path){
int v = scan_dir(path);
Serial.print("Total used in Dir \"" +path+ "\" = ");
Serial println(v);
}
unsigned long scan_dir(String path) {
Dir dir1 = SPIFFS.openDir(path);
unsigned long total_size = 0;
while (dir1.next()) {
if (dir1.isFile()){
Serial.print("File:\t");
Serial.print(path + dir1.fileName());
Serial.print("\tSize:\t");
unsigned long f_size = dir1.fileSize();
Serial.println(f_size);
total_size += f_size;
}
if (dir1.isDirectory()) {
unsigned long dsize = scan_dir(path+dir1.fileName()+"/");
Serial.print("Dir:\t");
Serial.print(path+dir1.fileName()+"/");
Serial.print("\tSize:\t");
Serial println(dsize);
total_size += dsize;
}
}
return total_size;
}
Can someone tell me why when using FSBrowser files that are created using commands are not visible? And how to make these files visible?