|
%!s(int64=4) %!d(string=hai) anos | |
---|---|---|
.. | ||
data | %!s(int64=4) %!d(string=hai) anos | |
extras | %!s(int64=4) %!d(string=hai) anos | |
FSBrowser.ino | %!s(int64=4) %!d(string=hai) anos | |
LICENSE | %!s(int64=4) %!d(string=hai) anos | |
README.md | %!s(int64=4) %!d(string=hai) anos |
It is a concrete implementation that applies AutoConnect to FSBrowser.ino which is an example of ESP8266WebServer library. A description of the specific changes can be found in the AutoConnect documentation.
Modifying just a few lines of the Sketch you have and applying AutoConnect has the following advantages:
The following description is a quote of readme.md that the FSBrowser distribution contains.
This example is a FileSystem Browser for the ESP8266 using http requests and a html/javascript frontend, working for all of SPIFFS, LittleFS and SDFS. This unified version is based on the previous examples named FSWebServer, FSBrowser and SDWebServer, Copyright (c) 2015 Hristo Gochkov. All rights reserved.
#define USE_xxx
directives in the sketchSTASSID
)data
folder to the filesystem. To do so:If you need to free some space on the ESP filesystem, you can delete all the sample files at the root but also replace the index.htm
file in the data/edit
subfolder by the index.htm.gz
file from the extras
folder. That compressed version is not suited for learning or debugging, but will bring the total FS usage under 7KB.
If you want to use the browser on a an existing filesystem or don't want to perform step 4 above, you have two possibilities :
index.htm
file to the filesystem by opening a command shell in the data
folder and running the following cURL command:
curl -F file=@edit/index.htm;filename=/edit/index.htm fsbrowser.local/edit
#define INCLUDE_FALLBACK_INDEX_HTM
That embedded version is functionally equivalent and will be returned if no /edit/index.htm
or /edit/index.htm.gz
file can be found on the filesystem, at the expense of a higher binary size.If you use the gzipped or INCLUDE_FALLBACK_INDEX_HTM
options, please remember to rerun the reduce_index.sh
script located in the extras
subfolder and recompile the sketch after each change to the index.html
file.
The html page uses the Ace.js (v1.4.9 at the time of writing) text editor which is loaded from a CDN. Consequently, internet access from your web browser is required for the FSBrowser editing feature to work as-is.
If your browser has no web access (e.g. if you are connected to the ESP8266 as an access-point), you can copy the ace.js
file to the edit
subfolder of the ESP filesystem, along with optional plugins etc. according to your needs. A typical set might be:
ace.js
ext-keybinding_menu.js
ext-searchbox.js
mode-html.js
worker-html.js
worker-css.js
worker-javascript.js
mode-xml.js
worker-xml.js
mode-json.js
worker-json.js
(see https://github.com/ajaxorg/ace-builds for a full list).
If ace.js
cannot be found on the ESP filesystem either, the page will default to a plain text viewer, with a warning message.
fileSystemConfig.setCSPin(chipSelectPin);
line, specifying the GPIO the CS pin is connected toindex.htm
is the default index returned if your URL does not end with a filename (works on subfolders as well)These tests are a checklist of operations to verify the FSBrowser behaviour.
Attempt creation of unsupported filenames
At root : MkFile '/My text file 1.txt' / List / Edit / Download / Delete / Upload '/My image file 1.png' / View image / Delete image
In subdir : MkFile '/My Directory/My text 2.txt' / List / Edit / Download / Delete / Upload '/My Directory/My image 2.png' / View image
Create nested file '/My folder/My test file.txt' and delete it
Create nested file '/a/b.txt' and delete file 'b.txt'
At root : MkFile '/My text file 1.txt' / List / Edit / Download / Delete / Upload '/My image file 1.png' / View image / Delete image / Mkdir '/My Directory'
In subdir : MkFile '/My Directory/My text file 2.txt' / List / Edit / Download / Delete / Upload '/My Directory/My image file 2.png' / View image / Mkdir '/My Directory/My Subdirectory'
Delete root folder '/My Directory'
Create nested file '/My folder/My test file.txt' and delete file 'My test file.txt'
Create nested file '/a/b.txt' and delete file 'b.txt', then delete '/a'
At root : MkFile '/My text file 1.txt' / List / Edit / Download / Delete / Upload '/My image file 1.png' / View image / Delete image / Mkdir '/My Directory'
In subdir : MkFile '/My Directory/My text file 2.txt' / List / Edit / Download / Delete / Upload '/My Directory/My image file 2.png' / View image / Mkdir '/My Directory/My Subdirectory'
Delete root folder '/My Directory'
Create nested file '/My folder/My test file.txt' and delete file 'My test file.txt'