Page 1 of 1

Send file to ESPeasy

Posted: 04 Nov 2019, 19:50
by ingoiot
hi,
can i send a file directly to the esp without using the buildin fliebrowser?
i'd like to send a dashbord.htm via app.

Re: Send file to ESPeasy

Posted: 04 Nov 2019, 21:01
by TD-er
I never tried it, but it should be possible using POST.
Note that some files cannot be overwritten like this, but any file with .htm extension does not have a protection filter.

Re: Send file to ESPeasy

Posted: 04 Nov 2019, 21:23
by ingoiot
tnx, ill try it

Re: Send file to ESPeasy

Posted: 12 Nov 2019, 18:53
by tiomny
Yes, POST request to http://<ESPEasy Ip>/upload uploads a file to filesystem. Besides, you can update the firmware using /update path.

Re: Send file to ESPeasy

Posted: 14 Nov 2019, 09:08
by riker1
same for rules....

you can upload rules with curl

for rule 1 filename has to be rules1.txt and so on....

Code: Select all

[curl -v -F upload=@"/path/filename"  http:<IP>/upload/[code]

Re: Send file to ESPeasy

Posted: 14 Nov 2019, 11:18
by TD-er
riker1 wrote: 14 Nov 2019, 09:08

Code: Select all

curl -v -F upload=@"/path/filename"  http:<IP>/upload/
Shouldn't there be a "//" between http:<IP>
?

Re: Send file to ESPeasy

Posted: 06 Dec 2019, 13:48
by riker1
Hi

of course you are right:

Code: Select all

[curl -v -F upload=@"/path/filename"  http://<IP>/upload/[code]

Re: Send file to ESPeasy

Posted: 17 Mar 2021, 12:23
by etardioli
Hi! im playing with app inventor and espeasy. Is there a way to POST rules (like rules1.txt) with URL commands?
i know its possible with curl. but with url?
Thanks in advance!

Re: Send file to ESPeasy

Posted: 17 Mar 2021, 12:32
by TD-er
You can have a look with the 'inspect' window of your browser to see how the rules are now saved from the web interface.
It is now using a JavaScript to "upload" the rules file you try to save.
In the past we used a POST command containing the entire rules for that file, but that POST message was kept in memory a few times and thus causing issues.
Some experienced a max of 15xx bytes, some had issues with truncated files at 17xx bytes.
Now that we upload the files it is working fine, but that means you can also upload it the same way using some tool like CURL.

Re: Send file to ESPeasy

Posted: 17 Mar 2021, 12:40
by etardioli
i will try at home later! thanks!

Re: Send file to ESPeasy

Posted: 22 Mar 2021, 05:22
by etardioli
well, i try as you suggested and switching between rules in can see this:

http://192.168.1.30/rules?set=2&rules=% ... ndon%0D%0A

First time works, but when i try today nothing happens...

Re: Send file to ESPeasy

Posted: 22 Mar 2021, 10:35
by TD-er
That's a HTTP GET request.
I find it hard to believe this GET url does actually create a rules file with the contents suggested in the URL.

Like I said, the handling of the content of the rules file in either a GET url or a POST request must be stored in RAM and this will cause issues like lost data or even a completely empty rules file.
So you should use the upload as is also done in the JavaScript, which you can see using the inspect window of your browser and then looking at the "Network" tab of it.

Just to explain the differences:
- HTTP GET url is an URL you can bookmark. Everything is in the URL.
- HTTP POST request is used to send data to the ESP to create/update settings. Typically the content of a web form is sent via HTTP POST.

The /upload page on ESPEasy does have a handler for GET, but that's only to show the web page.
There is also a handler for POST on that url, which is using specific headers to signal an upload.
See for some examples: https://stackoverflow.com/a/28193031
But I strongly suggest to check what's being sent when you submit something on the rules page by using the Network tab on the inspect window of your browser (right mouse button => inspect)