I'm taking pictures with ESP32-CAM and sending them through a temporary free trial API. When I set the camera to QQVGA it works. Photos are being sent.
Any resolution above this, for example QVGA, gives an error and does not send.
Searching on google I came to this post:
In the middle of the page the colleague Mikkel made a change in the cpp file, I changed my cpp file here according to Mikkel's example. But it was no use. I'm using HTTPClient.h version 1.2.
The snippet of my code that deals with this is this below.
Everything works perfectly if the camera resolution is QQVGA.
I'm trying to put a delay to give the URL time to be created due to the large size of the image (base64) in formats larger than QQVGA.
It looks like there is a debug tool to see what exactly the error is, but I've never used it.
Any help is always welcome.
My question is if anyone has a code snippet using the HTTPClient that sends large files and if they could post it here for me to use as an example.
If you don't want to help, please don't disturb those who would like to help.
Your code doesn't do the same. The code in the link posts some large data, your code just sends the URL again.
What error? If the error came from the remote site that is the most important information.
What is the remote site? Does it implement all of today's standards? Then a hunked upload may be a solution. How large is your upload payload actually?
URL-encoding makes it bigger, so the overhead of a multipart upload may be justified, given the remote site supports that.
I'll contact API support and get back here with info.
I copied and pasted the entire URL (with the picture in base64) in the google chrome bar and also in another site that sends URLs in the POST method. Both gave the error URI too long.
I researched a lot, and also this link. But the image I am uploading is the photo that the esp32 cam takes. This photo is converted to base64, then added to the URL.
I mean, this is the problem. When I increase the quality of the photo, the URL is so long that it gives the error URI too long and does not send.
I cannot send the photo to a website, web server, telegram, etc. It has to be like this, take the picture, encrypt base64 and send it along with the URL.
Oops, how are you? I was rooting for you to show up, lol.
I apologize if I didn't reveal the site/api, but this is it.
I'm just testing.
This link goes straight to the documentation that uploads images.
With this information you might want to modify something in the code of your previous topic (#6)
But I copied and pasted the entire URL both in the chrome bar browser and in a site that sends the URL through the POST method and both gave the error URI too long.
If the API support in sent the format of a URL for images, and it really works for small images. If I just change the base64 code of the photo for a slightly larger photo and it gives an error when I try to send it through this site:
This means that it is the API that is not able to receive large URLs and not the arduino IDE code.
That is, while you are giving this error using the website described above. It will be a waste of time to make any attempt to correct the code in the arduino IDE.
Are you trying to encode and send whole image as URL?
HTTP POST method used data section rather than URL, please see the examples to the HttpClient library
As per the information I provided above. I received from API support a URL (it's in the posts above) containing the necessary fields including the image code in base64 format. It works. But when I change the base64 code to one of a larger picture, it gives the error 414 URI too long
const char * url ="https://api.ultramsg.com/instance27986/messages/image";
http.begin(client, url);
// If you need Node-RED/server authentication, insert user and password below
//http.setAuthorization("REPLACE_WITH_SERVER_USERNAME", "REPLACE_WITH_SERVER_PASSWORD");
// Specify content-type header
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
// Data to send with HTTP POST
String httpRequestData = "api_key=tPmAT5Ab3j7F9&sensor=BME280&value1=24.25&value2=49.54&value3=1005.14";
// Send HTTP POST request
int httpResponseCode = http.POST(httpRequestData);
I already saw it, I tried to adapt it, I'll try it again now because if that solves the problem I must have done something wrong. I will be back in a moment.
I just don't understand why I did it as the chat support told me and it works with small images.
I will try this in my code. I will be back in a moment.
I have no idea if this will work with your server, but the fact that the length of the url has limitations and you can’t put a whole big image into it is obvious.