From b6d895293262c4395f4c8b24fdf31b01b462a75a Mon Sep 17 00:00:00 2001 From: Sascha Date: Tue, 1 Mar 2022 17:42:06 +0100 Subject: [PATCH] directory upload --- html/management_DE.html | 3 ++- src/HTMLmanagement_DE.h | 3 ++- src/Web.cpp | 19 +++++++++++++++++++ src/revision.h | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/html/management_DE.html b/html/management_DE.html index 1e6b5d9d5..c954e858c 100644 --- a/html/management_DE.html +++ b/html/management_DE.html @@ -243,7 +243,8 @@
- Browse + Dateien + Ordner Upload diff --git a/src/HTMLmanagement_DE.h b/src/HTMLmanagement_DE.h index 886bd873b..1e9fe9402 100644 --- a/src/HTMLmanagement_DE.h +++ b/src/HTMLmanagement_DE.h @@ -243,7 +243,8 @@ static const char management_HTML[] PROGMEM = "\
\ \ \ - Browse\ + Dateien\ + Ordner\ Upload\ \ \ diff --git a/src/Web.cpp b/src/Web.cpp index 34681c19a..1fdf6508c 100644 --- a/src/Web.cpp +++ b/src/Web.cpp @@ -672,6 +672,22 @@ void onWebsocketEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsE } } +void explorerCreateParentDirectories(const char* filePath) { + char tmpPath[MAX_FILEPATH_LENTGH]; + char *rest; + + rest = strchr(filePath, '/'); + while (rest) { + if (rest-filePath != 0){ + memcpy(tmpPath, filePath, rest-filePath); + tmpPath[rest-filePath] = '\0'; + printf("creating dir \"%s\"\n", tmpPath); + gFSystem.mkdir(tmpPath); + } + rest = strchr(rest+1, '/'); + } +} + // Handles file upload request from the explorer // requires a GET parameter path, as directory path to the file void explorerHandleFileUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { @@ -695,6 +711,9 @@ void explorerHandleFileUpload(AsyncWebServerRequest *request, String filename, s Log_Println(Log_Buffer, LOGLEVEL_INFO); Web_DeleteCachefile(utf8FilePath.c_str()); + // Create Parent directories + explorerCreateParentDirectories(utf8FilePath.c_str()); + // Create Ringbuffer for upload if (explorerFileUploadRingBuffer == NULL) { explorerFileUploadRingBuffer = xRingbufferCreate(8192, RINGBUF_TYPE_BYTEBUF); diff --git a/src/revision.h b/src/revision.h index 8f6d85067..a32b4cc87 100644 --- a/src/revision.h +++ b/src/revision.h @@ -1,4 +1,4 @@ #ifndef __REVISION_H__ #define __REVISION_H__ - constexpr const char softwareRevision[] PROGMEM = "Software-revision: 20220228-1"; + constexpr const char softwareRevision[] PROGMEM = "Software-revision: 20220301-1"; #endif \ No newline at end of file