How to send encoded image using HTTP POST? ESP32

zarar384
Posts: 6
Joined: Fri Mar 06, 2020 2:18 pm

How to send encoded image using HTTP POST? ESP32

Postby zarar384 » Thu Mar 12, 2020 10:32 pm

Hello.
I can’t figure out how to send an image encoded via base64 via HTTP POST.
I encode the image through base64:

Code: Select all

String base64image = base64::encode(fb->buf, fb->len);
Serial.println(base64image);
Trying to send using HTTP POST:

Code: Select all

if (!camClient.connect(postHost, postHttpPort))
  {
 
    camClient.println("POST /test/image/post.php HTTP/1.0");
    camClient.println("Host: cloud.****.com");
    camClient.println("Accept: */*");
    camClient.println("Content-Length: " +  base64image);
    camClient.println("Content-Type: image/jpeg");
    camClient.println();
    return;
   
  }

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: How to send encoded image using HTTP POST? ESP32

Postby chegewara » Fri Mar 13, 2020 8:07 pm

Code: Select all

camClient.println("Content-Length: " +  base64image);
This header is to post content length, not content itself.

For sure you can find arduino example how to do it in arduino-esp32 repository.

Who is online

Users browsing this forum: No registered users and 64 guests