Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerlembke committed Aug 24, 2023
1 parent 9271c47 commit d86decd
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 7 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

ESP32 File Manager for Generation Klick

[image](https://github.com/holgerlembke/ESPFMfGK/blob/main/img/bild1.jpg)

![this is it](https://raw.githubusercontent.com/holgerlembke/ESPFMfGK/main/img/bild1.png)
![this is it](https://raw.githubusercontent.com/holgerlembke/ESPFMfGK/main/img/bild1.jpg)


ESPFMfGK is a simple to use web interface that allows you to upload files with drag and drop, download files, edit files, move files and much more within your ESP32 file space. It supports all file systems (FFAT, SD, SD-MMC, LittleFS, SPIFFS) and an unlimited number of devices all at the same time.

[image](https://github.com/holgerlembke/ESPFMfGK/blob/main/img/bild2.jpg)

[image](https://github.com/holgerlembke/ESPFMfGK/blob/main/img/bild3.jpg)
![this is it](https://raw.githubusercontent.com/holgerlembke/ESPFMfGK/main/img/bild2.jpg)

![this is it](https://raw.githubusercontent.com/holgerlembke/ESPFMfGK/main/img/bild3.jpg)

ESPFMfGK is the successor of Award Winning https://github.com/holgerlembke/ESPxWebFlMgr.

Expand Down
104 changes: 104 additions & 0 deletions examples/advanced/ESPFMfGKdropin.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// Adds the filé systems
void addFileSystems(void) {
// This adds the Storage into the Filemanager. You have to at least call one of those.
// If you don't, begin() will fail. Because a Filemanager without files is useless.

/**/ //<-- Addd space there like this /** /
if (FFat.begin(true)) {
if (!filemgr.AddFS(FFat, "Flash/FFat", false)) {
Serial.println(F("Adding FFAT failed."));
}
} else {
Serial.println(F("FFat File System not inited."));
}
/**/

/**/
if (SD_MMC.begin("/sdcard", true)) {
if (!filemgr.AddFS(SD_MMC, "SD-MMC-Card", false)) {
Serial.println(F("Adding SD_MMC failed."));
}
} else {
Serial.println(F("SD_MMC File System not inited."));
}
/**/

/**/
const byte SS = 5; // D8
if (SD.begin(SS)) {
if (!filemgr.AddFS(SD, "SD-Card", false)) {
Serial.println(F("Adding SD failed."));
}
} else {
Serial.println(F("SD File System not inited."));
}
/**/
}

uint32_t checkFileFlags(fs::FS &fs, String filename, uint32_t flags) {

// this will hide system files (in my world, system files start with a dot)
if (filename.startsWith("/.")) {
// no other flags, file is invisible and nothing allowed
return ESPFMfGK::flagIsNotVisible;
}

// Checks if target file name is valid for action. This will simply allow everything by returning the queried flag
if (flags & ESPFMfGK::flagIsValidAction) {
return flags & (~ESPFMfGK::flagIsValidAction);
}

// Checks if target file name is valid for action.
if (flags & ESPFMfGK::flagIsValidTargetFilename) {
return flags & (~ESPFMfGK::flagIsValidTargetFilename);
}

// Default actions
uint32_t defaultflags = ESPFMfGK::flagCanDelete | ESPFMfGK::flagCanRename | ESPFMfGK::flagCanGZip | // ^t
ESPFMfGK::flagCanDownload | ESPFMfGK::flagCanUpload; // ^t

// editable files.
const String extedit[] PROGMEM = { ".html", ".css", ".js", ".txt", ".json", ".ino" };

filename.toLowerCase();
// I simply assume, that editable files are also allowed to be previewd
for (int i = 0; i < sizeof(extedit) / sizeof(extedit[0]); i++) {
if (filename.endsWith(String(extedit[i]))) {
defaultflags |= ESPFMfGK::flagCanEdit | ESPFMfGK::flagAllowPreview;
break;
}
}

const String extpreview[] PROGMEM = { ".jpg", ".png" };
for (int i = 0; i < sizeof(extpreview) / sizeof(extpreview[0]); i++) {
if (filename.endsWith(String(extpreview[i]))) {
defaultflags |= ESPFMfGK::flagAllowPreview;
break;
}
}


return defaultflags;
}

void setupFilemanager(void) {
// See above.
filemgr.checkFileFlags = checkFileFlags;

filemgr.WebPageTitle = "FileManager";
filemgr.BackgroundColor = "white";
filemgr.textareaCharset = "accept-charset=\"utf-8\"";

if ((WiFi.status() == WL_CONNECTED) && (filemgr.begin())) {
Serial.print(F("Open Filemanager with http://"));
Serial.print(WiFi.localIP());
Serial.print(F(":"));
Serial.print(filemanagerport);
Serial.print(F("/"));
Serial.println();
} else {
Serial.print(F("Filemanager: did not start"));
}
}

//
53 changes: 53 additions & 0 deletions examples/advanced/advanced.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
This example is a plain vanilla ESPFMfGK totally open and active features for anything.
It might be good solution for everything that will be used on the bench only. But keep
in mind: it is open as f*ck and anyone can delete/modify/see everything.
*/

#include <WiFi.h>
#include <FS.h>
// Remove the file systems that are not needed.
#include <SD.h>
#include <LittleFS.h>
#include <SD_MMC.h>
#include <FFat.h>
#include <SPI.h>
// the thing.
#include <ESPFMfGK.h>

// have a look at this concept to keep your private data safe!
// https://github.com/holgerlembke/privatedata
// #include <privatedata.h>


const word filemanagerport = 8080;
// we want a different port than the webserver
ESPFMfGK filemgr(filemanagerport);


void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("\n\nESPFMfGK plain demo");

// login into WiFi
// Change needed!
WiFi.begin("change", "here");
while (WiFi.status() != WL_CONNECTED) {
delay(10);
}

addFileSystems();
setupFilemanager();


}

void loop() {
filemgr.handleClient();
}

//
2 changes: 1 addition & 1 deletion src/ESPFMfGK.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
For compatibility reasons, the fileManagerServerStaticsInternally is activated by default.
*/
// #define fileManagerServerStaticsInternally
#define fileManagerServerStaticsInternally
// #define fileManagerServerStaticsInternallyDeflate


Expand Down

0 comments on commit d86decd

Please sign in to comment.