Skip to content

Commit

Permalink
filemanger with dir issue
Browse files Browse the repository at this point in the history
  • Loading branch information
vitotai committed Dec 15, 2023
1 parent 3f7defc commit 509e739
Show file tree
Hide file tree
Showing 2 changed files with 331 additions and 318 deletions.
18 changes: 17 additions & 1 deletion src/ESPUpdateServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,23 @@ static void handleFileDelete(void){
server.send(200, "text/plain", "");
path = String();
}
static void handleDirCreate(void){

if(server.args() == 0)
return server.send(500, "text/plain", "BAD ARGS");
String path = server.arg(0);
DBG_PRINTLN("handleDirCreate: " + path);
if(path == "/")
return server.send(500, "text/plain", "BAD PATH");
if(FileSystem.exists(path))
return server.send(500, "text/plain", "FILE EXISTS");

if(FileSystem.mkdir(path)){
server.send(200, "text/plain", "");
}else{
server.send(500, "text/plain", "CREATE FAILED");
}
}
static void handleFileCreate(void){
if(server.args() == 0)
return server.send(500, "text/plain", "BAD ARGS");
Expand Down Expand Up @@ -340,7 +356,7 @@ void ESPUpdateServer_setup(const char* user, const char* pass){
server.send_P(200,"text/html",edit_htm_gz,edit_htm_gz_len);
});
//create file
server.on("/edit", HTTP_PUT, handleFileCreate);
server.on("/edit", HTTP_PUT, handleDirCreate);
//delete file
server.on("/edit", HTTP_DELETE, handleFileDelete);
//first callback is called after the request has ended with all parsed arguments
Expand Down
Loading

0 comments on commit 509e739

Please sign in to comment.