compare event based handling of post-request with piping #1279
Replies: 20 comments
-
Posted at 2017-03-16 by @gfwilliams Looks like it could be a bug. Do you think you could come up with a full (but minimal) example (ideally with a server, and a client that performs the request) that I can run on a Linux build of Espruino? I can try and track this down a bit more easily then. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-16 by JumJum Hopefully this helps (and there is no typo in text :-) ). First see attached files.
BTW, looks like different sd cards result in different size for Upload piped Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-17 by @gfwilliams Which board is this on? Did you try it on the Linux Espruino build? That would be so much easier for me - especially when it comes to trying to debug this |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-17 by JumJum Sorry, I don't have a linux build. My Ubuntu server is leased in the internet, and my laptop has windows. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-17 by @gfwilliams I just looked in to this, and it's a few issues.
So:
And that's it - it should work. The whole pipe overflowing thing is a pain, but I don't see a nice way around it unless the pipe is allowed to ignore the chunksize argument when it sees that it has a bunch of data available for it - but that could cause problems for endpoints that really only do want small amounts of data. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-17 by @gfwilliams Also, I had to spend ages getting your code running under Linux first. In future it's easy to spin up a VM or even use a raspberry pi. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-17 by JumJum Oh, hopefully, your kids will recognize that old man at the door ;-) Thanks for your feedback. I will do as suggested. BTW, do you know about any guideline about setting up a VM for Espruino on Windows 10. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-17 by Wilberforce @jumjum
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-20 by @gfwilliams
:) I had to add some print statements to figure out what was happening at first, but the URLs requested all start with
Wrong location I'm afraid - they are called when the pipe closes, but the pipe only closes when the socket closes (at least in Espruino) - and the socket never closes because As @wilberforce says, using Ubuntu on Windows is pretty nice. With the new Espruino builds you may have to do |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-27 by Wilberforce @gordon any chance you could post your code - I would like to see where you put the end handler. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-27 by @gfwilliams Sure, the code I ended up using was:
So basically I call |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-27 by Wilberforce Thanks |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-27 by Wilberforce I'm looking at using the file upload input element with the multi-part encoding, so that files can be uploaded including binary files. Can you think of a cunning way of decoding the multi-part message? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-27 by @gfwilliams |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-28 by Wilberforce Thanks Gordon. Decoding the post boundarys is quite difficult so I decided to do it the easy way - put the file content as the body and just stream that up. So this lets the browser do all the hard work instead... It allows you to select a file and upload it using the PUT method... insteading pasting the file contents. It should allow binary files too. Next steps are to clean up the look, and allow folder creation and folder selection..... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-03-28 by Wilberforce
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-01-16 by barbiani @wilberforce I am following your example, but I am not seeing the complete file save in the flash. File index.htm size is 4752, printed POST data is "cRcv": 4752, but file in flash does not match. I know that the problem is not in the filesystem, because using "multipart/form-data" on the form post I get the complete file... plus some added strings like this: ------WebKitFormBoundaryZ2Lus84JA68itxnM ...html file contents... ------WebKitFormBoundaryZ2Lus84JA68itxnM--
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-01-16 by @gfwilliams I had some code for handling multipart form data here if it helps:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-01-17 by barbiani Thank you Gordon. I will give it a try. I saw that the espruino tool is capable of placing a file in the storage area, but it seems that this is only for the original espruinos. EDIT: It worked perfectly. Had to make 'var boundary = "";' else it would complain about it not having the .length property. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-01-17 by @gfwilliams That's strange - |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2017-03-16 by JumJum
Project is to support uploading of files and save on SD.
It is tested on ESP32, I don't have hardware to compare with espruino board.
If this is a ESP32 problem only, please move it to ESP32 forum.
Doing the job with piping does not save full upload, some data at the end is missing
Doing same without piping works fine
Beta Was this translation helpful? Give feedback.
All reactions