ayushsharma82 / ESP-DASH

Blazing fast library to create a functional, on-device dashboard for ESP8266 / ESP32 / RP2040
https://espdash.pro
GNU General Public License v3.0
978 stars 200 forks source link

Upload card #197

Closed mathieucarbou closed 3 months ago

mathieucarbou commented 10 months ago

Please add an upload card with a file input allowing to chose a file. The file can just be passed as a form to an existing implemented upload handler in the app. No need for ESP-DASH to handle the file upload.

Note: this feature is implemented in my private fork fyi

ayushsharma82 commented 9 months ago

Didn't include it in 4.4.0 release as I think it will be too hard for a casual user to understand all the moving parts. Maybe we can create a ESP-DASH wrapper for uploads to make it easy.

elliotmatson commented 5 months ago

This is interesting, were y'all still planning to look further into this? I'm working on a distributed sensor system using ESP-WiFi-MESH, and the base station is managed using ESP-DASH-Pro. It would be really useful to have a card to upload a bin file for all the sensor nodes, that the base station can then push the update to them over the mesh

mathieucarbou commented 5 months ago

@elliotmatson : it is implemented in my pro version.

image image


  webServer
    .on(
      "/api/config/restore",
      HTTP_POST,
      [](AsyncWebServerRequest* request) {
        AsyncWebServerResponse* response = request->beginResponse(200, "text/plain", "OK");
        if (!LittleFS.exists("/config.txt")) {
          return request->send(400, "text/plain", "No config.txt file uploaded");
        }
        File cfg = LittleFS.open("/config.txt", "r");
        const String data = cfg.readString();
        cfg.close();
        config.restore(data);
        response->addHeader("Connection", "close");
        response->addHeader("Access-Control-Allow-Origin", "*");
        request->send(response);
      },
      [](AsyncWebServerRequest* request, String filename, size_t index, uint8_t* data, size_t len, bool final) {
        if (!index)
          request->_tempFile = LittleFS.open("/config.txt", "w");
        if (len)
          request->_tempFile.write(data, len);
        if (final)
          request->_tempFile.close();
      })
    .setAuthentication(YASOLR_ADMIN_USERNAME, config.get(KEY_ADMIN_PASSWORD));

Overall, this works fine but there are too many moving piece to setup outside of the project to make it easy for everybody.

mathieucarbou commented 5 months ago

@ayushsharma82 : I'm think it would be trivial to have this code embeded in ESP-DASH... I might try something and will let you know if I succeed,

mathieucarbou commented 5 months ago

@ayushsharma82 : I'm think it would be trivial to have this code embeded in ESP-DASH... I might try something and will let you know if I succeed,

Ok so I was able to do something quick but reverted: this is really not a good idea to have that inside EASP-ASH because we need to create File and it would for a dependency over something (LittleFS, SD, etc)

It is better that the user does its own upload implemntation.

Moreover, some users might want to always save in the same dest filename, some different filename, some would like teh filename taken from the upload, etc. So its not possible for a lib to account for all these particular usages.

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 3 months ago

This issue was closed because it has been stalled for 5 days with no activity.