Home › Forums › The libraries hosted on the site › Simple FTP Server › Server working but directory always empty
- This topic has 4 replies, 2 voices, and was last updated 1 month, 1 week ago by
monaco87.
-
AuthorPosts
-
-
18 March 2025 at 16:29 #32300
Hi,
I have an ESP32 application which logs to a LittleFS root. Each time the log file is updated I send a directory listing to the serial port and I can see the file under “/” and its size, which has increased.
When I connect to the FTP server and “dir” or “ls” I get:
227 Entering Passive Mode (192,168,XXXXXXXXXX) 150 Accepted data connection to port 50009 226 0 matches total
“pwd” shows that I am indeed in “/”
Any ideas?
-
23 March 2025 at 08:11 #32315
Hi Monaco,
I tried It, and it seems to work. Can you explain the step you did?
Bye Renzo -
24 March 2025 at 22:48 #32318
Hi, thanks for replying.
Setup:
#define DEFAULT_STORAGE_TYPE_ESP32 STORAGE_LITTLEFS #include <SimpleFtpServer.h> FtpServer ftpSrv; void setup() { Serial.begin(115200); if (!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED)) { Serial.println("LittleFS Mount Failed"); } else { Serial.println("LittleFS Mounted OK"); } delay(3000); }
Code to create test file and list FS contents:
void updateTestFile(String data) { if (!LittleFS.exists("/ign_log.txt")) { File file = LittleFS.open("/ign_log.txt", FILE_WRITE); if (!file) { Serial.println("There was an error opening ign_log.txt for writing"); return; } file.close(); } File file = LittleFS.open("/ign_log.txt", FILE_APPEND); if (!file) { Serial.println("- failed to open file for appending"); return; } if (file.print(data)) { Serial.println("- data appended"); } else { Serial.println("- append failed"); } file.close(); getFileList(); } void getFileList() { Serial.printf("Listing directory: %s\r\n", "/"); File root = LittleFS.open("/"); if (!root) { Serial.println("- failed to open directory"); return; } if (!root.isDirectory()) { Serial.println(" - not a directory"); return; } File file = root.openNextFile(); while (file) { if (file.isDirectory()) { Serial.print(" DIR : "); Serial.println(file.name()); // if (levels) // { // listDir(SPIFFS, file.path(), levels - 1); // } } else { Serial.print(" FILE: "); Serial.print(file.name()); Serial.print("\tSIZE: "); Serial.println(file.size()); } file = root.openNextFile(); } }
Then the loop:
ftpSrv.begin("abc","abc"); while (true) { ftpSrv.handleFTP(); }
getFileList() displays the test file and size on the serial console.
I then manually ftp to the device from a bash shell, connection and login are fine. Commands ‘dir’ and ‘ls’ give zero files.
Partition is default 4MB sith SPIFFS (12.MB APP, 1.5MB SPIFFS)
-
27 March 2025 at 08:27 #32323
Hi monaco,
modify#define DEFAULT_STORAGE_TYPE_ESP32 STORAGE_LITTLEFS
directly inSimpleFTPServerKey.h
it can’t manage from the external.
Bye Renzo -
28 March 2025 at 15:56 #32327
Renzo,
Thank you very much, that fixed it – dumb mistake on my part.
Thanks for the great software and the great help !
-
-
AuthorPosts
- You must be logged in to reply to this topic.