HTTPS Multipart File Transfer to Server

User avatar
gunar.kroeger
Posts: 127
Joined: Fri Jul 27, 2018 6:48 pm

HTTPS Multipart File Transfer to Server

Postby gunar.kroeger » Thu Oct 25, 2018 8:29 pm

Hi again!

I am required to upload files from SD card to a server with a specified url and header using multipart request
I have already successfully used esp_http_client example and was able to use POST commands to send data to the specified url through HTTPS.
But I couldn't find an example on how to send files with multipart protocol.

Could someone guide me to the information needed to perform this task? links, libraries or examples would be appreciated!
Reading from SD card is not the problem. It's the sending of the chunks that I don't understand.

Thanks (:
"Running was invented in 1612 by Thomas Running when he tried to walk twice at the same time."

User avatar
gunar.kroeger
Posts: 127
Joined: Fri Jul 27, 2018 6:48 pm

Re: HTTPS Multipart File Transfer to Server

Postby gunar.kroeger » Mon Oct 29, 2018 4:26 pm

So, from what I understand so far, Multipart request is just a regular POST message.

I have to
1. esp_http_client_init
2. esp_http_client_set_header for each header needed in the multipart request protocol
3. esp_http_client_open
4. esp_http_client_write every chunk of the file I wish to send
5. esp_http_client_fetch_headers of the response
6. esp_http_client_read to read the response

from what I understand, I can't use a simple esp_http_client_perform because the files are too large to be loaded into memory
Is all this correct? I will test my theory as soon as I can

thanks
"Running was invented in 1612 by Thomas Running when he tried to walk twice at the same time."

User avatar
gunar.kroeger
Posts: 127
Joined: Fri Jul 27, 2018 6:48 pm

Re: HTTPS Multipart File Transfer to Server

Postby gunar.kroeger » Tue Oct 30, 2018 2:37 pm

This works! I have been able to send small files to the server.
I came across another problem for larger files but I think I should open another thread for it
"Running was invented in 1612 by Thomas Running when he tried to walk twice at the same time."

jfernandes
Posts: 1
Joined: Wed Sep 25, 2019 9:25 am

Re: HTTPS Multipart File Transfer to Server

Postby jfernandes » Wed Sep 25, 2019 9:29 am

Hello @gunar.kroeger,

By any chance could you post your code that you used to send files to server? Im in the same boat at the moment. I have got basic small byte files (128 bytes ish) going up no problem using just the wireless client, but I would like to send some larger sensor log files across. How big were your files that you got successfully sent?

Thank you

Who is online

Users browsing this forum: Google [Bot] and 54 guests