Send file to ESPeasy

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ingoiot
Normal user
Posts: 83
Joined: 15 Aug 2019, 22:09

Send file to ESPeasy

#1 Post by ingoiot » 04 Nov 2019, 19:50

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.

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Send file to ESPeasy

#2 Post by TD-er » 04 Nov 2019, 21:01

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.

ingoiot
Normal user
Posts: 83
Joined: 15 Aug 2019, 22:09

Re: Send file to ESPeasy

#3 Post by ingoiot » 04 Nov 2019, 21:23

tnx, ill try it

tiomny
Normal user
Posts: 31
Joined: 23 Sep 2019, 20:11

Re: Send file to ESPeasy

#4 Post by tiomny » 12 Nov 2019, 18:53

Yes, POST request to http://<ESPEasy Ip>/upload uploads a file to filesystem. Besides, you can update the firmware using /update path.

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: Send file to ESPeasy

#5 Post by riker1 » 14 Nov 2019, 09:08

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]

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Send file to ESPeasy

#6 Post by TD-er » 14 Nov 2019, 11:18

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>
?

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: Send file to ESPeasy

#7 Post by riker1 » 06 Dec 2019, 13:48

Hi

of course you are right:

Code: Select all

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

etardioli
New user
Posts: 8
Joined: 17 Mar 2021, 05:59

Re: Send file to ESPeasy

#8 Post by etardioli » 17 Mar 2021, 12:23

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!

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Send file to ESPeasy

#9 Post by TD-er » 17 Mar 2021, 12:32

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.

etardioli
New user
Posts: 8
Joined: 17 Mar 2021, 05:59

Re: Send file to ESPeasy

#10 Post by etardioli » 17 Mar 2021, 12:40

i will try at home later! thanks!

etardioli
New user
Posts: 8
Joined: 17 Mar 2021, 05:59

Re: Send file to ESPeasy

#11 Post by etardioli » 22 Mar 2021, 05:22

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...

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Send file to ESPeasy

#12 Post by TD-er » 22 Mar 2021, 10:35

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)

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests