Upload file of 250kB or more
Upload file of 250kB or more
Hello,
I have to write a program to upload files form 250kB or more to the ESP32. In the µPython we have the WebREPL. With this I can to do that. The file wil be sent and µPython saves it in the flash.
But I don't know how can I make a such in a µPython porgram.
Can someone help me with a tip?
I have to write a program to upload files form 250kB or more to the ESP32. In the µPython we have the WebREPL. With this I can to do that. The file wil be sent and µPython saves it in the flash.
But I don't know how can I make a such in a µPython porgram.
Can someone help me with a tip?
Re: Upload file of 250kB or more
You can use ftplib do startt downloading the file from an ftp server. I tested the version below adapted by @SpotlightKid and it worked fine- I had as ESP8266 subtree with a condensed version for board with small resources.
https://github.com/SpotlightKid/micropython-ftplib.git
https://github.com/SpotlightKid/micropython-ftplib.git
Re: Upload file of 250kB or more
Danke, Robert, ich guck mir das mal an!
Re: Upload file of 250kB or more
Hallo @Roberthh,
Du hast doch selber ein FTP-Modul programmiert. Ich habe das in meiner Not hier grade am Laufen. Im Moment geht's auch. Kann ich Dir denn dazu ein paar Fragen stellen?
Du hast doch selber ein FTP-Modul programmiert. Ich habe das in meiner Not hier grade am Laufen. Im Moment geht's auch. Kann ich Dir denn dazu ein paar Fragen stellen?
Re: Upload file of 250kB or more
Die erste wäre - Wie kann ich die im FTP-Client anzeigbaren Pfade einschränken.
Konkret: Wenn ich eine Verbindung vom ESP zu FileZilla herstelle, zeigt mir letzteres ja den Wurzelpfad "flash" an und damit alles, was auf dem ESP ist. Ich würde gern nur einen einzigen Pfad anzeigen lassen, damit ein User nicht auf die eigentlichen ESP-Programmdateien Zugriff hat.
Die zweite - Wie kann ich einen Passwort-Schutz vereinbaren?
Since this is an English forum, I'll continue in English (as good as I can):
--- Translated with deepl.com --
The first one would be - How can I restrict the paths that can be displayed in the FTP client.
To be precise: When I connect from ESP to FileZilla, the latter will show me the root path "flash" and with it everything that is on the ESP. I would like to have only one path displayed so that a user doesn't have access to the actual ESP program files.
The second - How can I setup a password protection?
---------------------
For both changes to have to change the uftpd script:
For the first option you can set a certain subdirectory as default home and not allowing to cd to a path different to that tree. The cwd variable always has the full path. So it#s simple to check that a new cwd always starts with the intended string. Obviously you have to check also all files accesses.
For the seconf option you have to insert appropriate code into the sections for the USER and PASS commands, which at the moment only sends the "OK" message. There are comments in these sections telling on how to implement user & password handling.
All of that happens between lines 223 and 255. So it is easy to find.
----- translated back with deepl. -----
Für beide Änderungen muss das uftpd-Skript geändert werden:
Für die erste Option kann ein bestimmtes Unterverzeichnis als Standard-Home-Verzeichnis festgelegt werden, wobei es nicht erlaubt ist, auf einen anderen Pfad als diesen Baum zu verweisen. Die Variable cwd hat immer den vollen Pfad. So ist es einfach zu überprüfen, ob ein neues cwd immer mit der beabsichtigten Zeichenfolge beginnt. Natürlich musst du auch alle Dateizugriffe überprüfen.
Für die zweite Option musst du entsprechenden Code in die Abschnitte für die USER- und PASS-Befehle einfügen, der im Moment nur die "OK"-Meldung sendet. In diesen Abschnitten gibt es Kommentare, wie man die Handhabung von Benutzer und Passwort implementiert.
All dies geschieht zwischen den Zeilen 223 und 255. Es ist also leicht zu finden
Konkret: Wenn ich eine Verbindung vom ESP zu FileZilla herstelle, zeigt mir letzteres ja den Wurzelpfad "flash" an und damit alles, was auf dem ESP ist. Ich würde gern nur einen einzigen Pfad anzeigen lassen, damit ein User nicht auf die eigentlichen ESP-Programmdateien Zugriff hat.
Die zweite - Wie kann ich einen Passwort-Schutz vereinbaren?
Since this is an English forum, I'll continue in English (as good as I can):
--- Translated with deepl.com --
The first one would be - How can I restrict the paths that can be displayed in the FTP client.
To be precise: When I connect from ESP to FileZilla, the latter will show me the root path "flash" and with it everything that is on the ESP. I would like to have only one path displayed so that a user doesn't have access to the actual ESP program files.
The second - How can I setup a password protection?
---------------------
For both changes to have to change the uftpd script:
For the first option you can set a certain subdirectory as default home and not allowing to cd to a path different to that tree. The cwd variable always has the full path. So it#s simple to check that a new cwd always starts with the intended string. Obviously you have to check also all files accesses.
For the seconf option you have to insert appropriate code into the sections for the USER and PASS commands, which at the moment only sends the "OK" message. There are comments in these sections telling on how to implement user & password handling.
All of that happens between lines 223 and 255. So it is easy to find.
----- translated back with deepl. -----
Für beide Änderungen muss das uftpd-Skript geändert werden:
Für die erste Option kann ein bestimmtes Unterverzeichnis als Standard-Home-Verzeichnis festgelegt werden, wobei es nicht erlaubt ist, auf einen anderen Pfad als diesen Baum zu verweisen. Die Variable cwd hat immer den vollen Pfad. So ist es einfach zu überprüfen, ob ein neues cwd immer mit der beabsichtigten Zeichenfolge beginnt. Natürlich musst du auch alle Dateizugriffe überprüfen.
Für die zweite Option musst du entsprechenden Code in die Abschnitte für die USER- und PASS-Befehle einfügen, der im Moment nur die "OK"-Meldung sendet. In diesen Abschnitten gibt es Kommentare, wie man die Handhabung von Benutzer und Passwort implementiert.
All dies geschieht zwischen den Zeilen 223 und 255. Es ist also leicht zu finden
Re: Upload file of 250kB or more
I had one week having trouble me with quite different things and am only now to read again.
Thank you!
I will send a feedback when I tried this.
Thank you!
I will send a feedback when I tried this.
Re: Upload file of 250kB or more
Hello,
I got away from using FTP because that's zu complicated for the future users.
The best way to transfered a file is the way from WebRepl. But withouth the REPL. I have to make a HTML site with a file functionality on base websockets. I took as start point the example from here:
https://github.com/danni/uwebsockets
For switch a LED or transmission with as UART is OK. But no for file transfer.
WebRepl uses an another websocket library. Where I can find this. I know the WebReplCilent.py only.
I got away from using FTP because that's zu complicated for the future users.
The best way to transfered a file is the way from WebRepl. But withouth the REPL. I have to make a HTML site with a file functionality on base websockets. I took as start point the example from here:
https://github.com/danni/uwebsockets
For switch a LED or transmission with as UART is OK. But no for file transfer.
WebRepl uses an another websocket library. Where I can find this. I know the WebReplCilent.py only.
- MostlyHarmless
- Posts: 166
- Joined: Thu Nov 21, 2019 6:25 pm
- Location: Pennsylvania, USA
Re: Upload file of 250kB or more
Robert's FTP Server funktioniert wunderbar mit curl(1).
Back to english as to not exclude anyone from the discussion.
If your preference is a browser based interface, I am wondering if there might be some JS library out there that can perform FTP like a file explorer. The ESP32 can perfectly serve that type of JS content via picoweb.
Blos 'ne Idee
Re: Upload file of 250kB or more
Thanks for the help!
I've no objection to Robert's FTP solution.
But, who should be used my control unit with the software that I've to make, somtimes has no idee about computer. The ESP-Unit should is supposed a connection beetwen a controlller unit an a smartphone/tablet/PC. For this is the first step to make an udate function. The user must able to load a file quickly ans easily onto the esp unit and this pushes it into the control unit bootloader.
I fear that some users are overwelmed with a ftp solution.
The ESP unit should also provide IoT functions. Because I think, I need a websocket solution anyway.
I've no objection to Robert's FTP solution.
But, who should be used my control unit with the software that I've to make, somtimes has no idee about computer. The ESP-Unit should is supposed a connection beetwen a controlller unit an a smartphone/tablet/PC. For this is the first step to make an udate function. The user must able to load a file quickly ans easily onto the esp unit and this pushes it into the control unit bootloader.
I fear that some users are overwelmed with a ftp solution.
The ESP unit should also provide IoT functions. Because I think, I need a websocket solution anyway.