Page 1 of 1

How to send encoded image using HTTP POST? ESP32

Posted: Thu Mar 12, 2020 10:32 pm
by zarar384
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;
   
  }

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

Posted: Fri Mar 13, 2020 8:07 pm
by chegewara

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.