Closed mathieucarbou closed 3 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.
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
@elliotmatson : it is implemented in my pro version.
I did create an upload card in the portal folder with a file input.
I use the card value to point to a path: /api/config/restore
: this path is used by the upload card javascript code to send the file in a form post
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.
@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,
@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.
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.
This issue was closed because it has been stalled for 5 days with no activity.
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