Page 1 of 1

File Server shows no files inside the directories

Posted: Thu Jul 21, 2022 12:27 pm
by esp-dev
Hello,

While I'm exploring the file sever example in the SDK: https://github.com/espressif/esp-idf/tr ... le_serving I was successful in connecting and visualising the files in the base_path.

Code: Select all

base_path = "/sdcard"
However, when I try to access the files inside the directory, it say file not exists, but on the ESP_LOG it says,

Code: Select all

I (5606) example: File server started
I (16456) file_server: Found directory : PREDICT (0 bytes)
E (34206) file_server: Failed to stat dir : /sdcard/PREDICT/
W (34206) httpd_txrx: httpd_resp_send_err: 404 Not Found - Directory does not exist
W (34216) httpd_uri: httpd_uri: uri handler execution failed
My directory looks something like this,

Code: Select all

.
└── predict
    ├──ZA_R01_1.jpg
    └── ZA_R01_2.jpg

1 directory, 2 files
What's missing in this? Do I need some config to access files inside the directory?

Re: File Server shows no files inside the directories

Posted: Thu Jul 21, 2022 4:48 pm
by esp-dev
Does it need some more information to look at it? Let me know I can provide.

Re: File Server shows no files inside the directories

Posted: Mon Jul 25, 2022 1:00 pm
by esp-dev
Update: I've played around the URI paths and came to know that, I'm able to access the files with it's absolute URLs, however, when it lists the directory, it is not listing the files inside it.

Since I'm new to web, I'm pretty much feeling confused. Some body worked with these kind of stuff?

Let me know, this will be helpful.

Re: File Server shows no files inside the directories

Posted: Mon Jul 25, 2022 1:18 pm
by abansal22
esp-dev wrote:
Thu Jul 21, 2022 12:27 pm
Hello,

While I'm exploring the file sever example in the SDK: https://github.com/espressif/esp-idf/tr ... le_serving I was successful in connecting and visualising the files in the base_path.

Code: Select all

base_path = "/sdcard"
However, when I try to access the files inside the directory, it say file not exists, but on the ESP_LOG it says,

Code: Select all

I (5606) example: File server started
I (16456) file_server: Found directory : PREDICT (0 bytes)
E (34206) file_server: Failed to stat dir : /sdcard/PREDICT/
W (34206) httpd_txrx: httpd_resp_send_err: 404 Not Found - Directory does not exist
W (34216) httpd_uri: httpd_uri: uri handler execution failed
My directory looks something like this,

Code: Select all

.
└── predict
    ├──ZA_R01_1.jpg
    └── ZA_R01_2.jpg

1 directory, 2 files
What's missing in this? Do I need some config to access files inside the directory?
Please note the following lines:
"Currently, SPIFFS does not support directories, it produces a flat structure. If SPIFFS is mounted under /spiffs, then creating a file with the path /spiffs/tmp/myfile.txt will create a file called /tmp/myfile.txt in SPIFFS, instead of myfile.txt in the directory /spiffs/tmp"

There are no directory in the spiffs, everything is file. Thats why the URI path opening the files. But you can make the program using regrex, list the files with name pattern "/PREDICT/*" and send it to front end. for more info click on this

https://docs.espressif.com/projects/esp ... piffs.html

Thanks
Ankit Bansal

Re: File Server shows no files inside the directories

Posted: Mon Jul 25, 2022 2:38 pm
by esp-dev
Ankit,

Thanks man. This clarifies things.