-->
Page 1 of 2

Doing an HTTP Upload twice

PostPosted: Wed Oct 17, 2018 5:26 pm
by Iksi
Hello,

I want to send a file from the Http Upload directly to an SoftSerial Port. For that purpose I need to know the exact size of the file because before starting to send the file i have to send the size of it.
I think there is nothing in the library to read the exact file size. So i thought about uploading the file twice.
At first upload i want only to check the size of it. Afterwards i want to start a second upload and send it via SoftSerial to an nextion Display.

The first upload is initiated by choosing the file in an file dialog and then pushing a button on the http page.

So how can i start the second upload without klicking any button on the http page ? Should work automatically after the first upload is done.

best regards Iksi

Re: Doing an HTTP Upload twice

PostPosted: Thu Oct 18, 2018 3:04 am
by QuickFix
I don't exactly understand what your goal is, but sending content twice *feels* as a very weird and unnecessary solution to me.
Normally one would use the content-length header value to determine the length, just like one would use content-disposition to get to the filename.

Re: Doing an HTTP Upload twice

PostPosted: Thu Oct 18, 2018 6:16 am
by Iksi
But the content length value gives me a value which is about 200byte larger than the file size I want to upload.
It is not exactly 200 byte larger, it can be 205 or 206.
I need the exact size of the file. So how can I calculate the real file size?

Re: Doing an HTTP Upload twice

PostPosted: Thu Oct 18, 2018 7:49 am
by QuickFix
Iksi wrote:So how can I calculate the real file size?

You have to extract the size of the header again (if I recall correctly, it has been a while).