DaveBrad / SPIFFS-DevFsUpload

A Arduino library that provides a browser GUI to upload/delete file(s) to SPIFFS and webpage devices (eg. ESP8266)
Other
0 stars 0 forks source link

LittleFS #1

Open roncoa opened 4 years ago

roncoa commented 4 years ago

Can you update DevFsUpload to use with LittleFS?

DaveBrad commented 4 years ago

I'm looking into LittleFS on three fronts. 1) have it coexist with SPIFFS code and be select-able for compile (some issues around this) so as to maintain a low ram foot-print. 2) Consider creating a DevFsUploadLittleFS sibliing library (if 1 does not work) 3) SPIFFS has a flat dir/file structure. Whereas LittleFS supports a directory/folder structure (with mkdir,....) and files [implying more methods to support and larger ram foot-print]

I'm looking at it and hopefully have a solution within a week or so.

roncoa commented 4 years ago

Thanks for your answer. Waiting for your solution, I modified your library to make it work with LittleFS. If it can be useful, I have: _ I replaced #include "FS.h" with include "LittleFS.h".

#include "LittleFS.h"
// # include "FS.h"

I replaced all the SPIFFS calls with LittelFS. I added the function "static void listDir (const char * dirname, WiFiClient client);"

void DevFsUpload :: listDir (const char * dirname, WiFiClient client) {
  Dir root = LittleFS.openDir (dirname);
  while (root.next ()) {
    if (root.fileSize ()) {
      File filee = root.openFile ("r");
String str = "<div>" + (String) filee.fullName () + "" + (String) filee.size () + "</div>";
cliente.println (str);
      filee.close ();
    }
    else {
      String tmp = root.fileName ();
      const char * tmp1 = tmp.c_str ();
      DevFsUpload :: listdir (tmp1, customer);
    }
  }
}

_ In "void DevFsUpload :: handleUploadPage ()" I substitute:

client.print ("<div class = 'scrl' tabindex = '- 1'> <div id = 'lsttab' class = 'bof dvtb'>");
Dir dir = LittleFS.openDir ("/");
while (dir.next ()) {
String str = "<div>" + dir.fileName () + "" + dir.fileSize () + "</div>";
//
// The above information will be changed to the following via a javascript client 'onload'
//
// String str = "<form class = 'frmRow' method = 'post'> <div class = 'tdi'> <input type = 'text' name = 'fname' readonly value = '";
// str + = dir.fileName ();
// str + = "'size ='";
// str + = len;
// str + = "'> </div> <div class =' ​​tdi siz '>";
// str + = dir.fileSize ();
// str + = "</div> <div class = 'tdi'> <input class = 'btt' type = 'submit' name = 'delete' value = 'Delete'> </div>";
// str + = "</form>";
client.println (str);
}
client.print ( "</ div> </ div> ');

with

client.print ("<div class = 'scrl' tabindex = '- 1'> <div id = 'lsttab' class = 'bof dvtb'>");
DevFsUpload :: listdir ( "/", client);
client.print ( "</ div> </ div> ');
roncoa commented 4 years ago

Since LittleSF also supports filenames> 8.3, in void DevFsUpload :: handleFileUpload () I also commented on these lines:

    //  if(fnLen > 12){
    //  // this could be a directory upload item
    //  int remaining = fnLen - fn.lastIndexOf("/") - 1;
    //  failDirFormat = remaining > 12;
    //  Serial.print("remaining ");
    //  Serial.println(remaining);
    // }
roncoa commented 4 years ago

I hope to be useful. I look forward to your final version. Thank you.

DaveBrad commented 4 years ago

I've a working LittleFS copy (my PC) but had to do more research than I expected. (LittleFS has an undocumented API and I had to guess/trial-and-error my way to a solution.) Support for directories is implemented; a few surprises in directory implementation.

I just need to sync with SPIFFS code so as to make the design similar. Plus need updated documentation for both SPIFFS and LittleFS so as to reflect the differences.

Unfortunately I have to "clone/duplicate" code from SPIFFS to LittleFS as a selector/preprocessor solution isn't possible with Arduiino IDE.

Hopefully will be done in the next few days.

roncoa commented 4 years ago

Perfect. I look forward to the new library.

DaveBrad commented 4 years ago

Try DaveBrad/DevFsUploadESP , it has documentation and provides more capability in managing files and directories on the ESP32 & ESP8266. Configs support are: ESP8266 - SPIFFS and LittleFS ESP32 - SPIFFS

At present LittleFS on ESP32 is in flux or poorly supported.

Sorry it took so long: had to do code optimization to reduce the PROGMEM and Variable stack storage usage.

roncoa commented 4 years ago

I'm trying it, it's excellent. I have a request, could you add a "DOWNLOAD" button? How does it work with ajax commands? Anyway, you did a great job, very good.

DaveBrad commented 4 years ago

Hi,

Download has been added and tested. Documentation updated.

Found a couple of issues along the way, also fixed those.

Ajax is a general term:

I'm going to look at using ajax for other actions. Want to lower the storage foot-print of DevFsUploadESP.

If you are looking at ajax for you own use, google "XMLHttpRequest", there's a ton of stuff on this in Javascript.

Thx