Skip to content

http.POST() Failure to send large files #1871

@HelloDB

Description

@HelloDB

Hardware:

Board: ESP32 Dev Module
Core Installation/update date: 2018-09-19
IDE name: Platform.io
Flash Frequency: 240Mhz
PSRAM enabled: no
Upload Speed: 115200
Computer OS: Windows 10

Description:

http.POST() Failure to send large files,For example, 30kbyte pictures.
When I narrowed the image to 10KB, I successfully sent it.

Sketch:

if (wifiMulti.run() == WL_CONNECTED) {

	String url = gFace_url_add + "?access_token=" + gFace_TK;
	
	char *output = new char[b64_enc_len(image_size)];
	size_t len = b64_encode(output, (char *)image, image_size);
	// Serial.write((uint8_t *)output, len);
	String data = "{\"group_id\":\"" + gSN + "\",\"user_id\":\"user_001\",\"user_info\":\"user_test\"," + // 图像信息
				  "\"image_type\":\"BASE64\",\"image\":\"" + output + "\"," +							  // 图像数据
				  "\"quality_control\":\"NORMAL\"," +													  // 图像质量要求,这里设置为一般
				  "\"liveness_control\":\"NORMAL\"" +													  // 活体检测控制,这是设置为一般
				  "}";

	// delete[] output;

	LOGln(url);
	// LOGln(data);
	HTTPClient http;
	http.begin(url);
	LOGln("http begin...");
	http.addHeader("Content-Type", "application/json");
	int httpCode = http.POST(data);
	if (httpCode > 0) {
		LOGf("POST... code: %d\n", httpCode);
		if (httpCode == HTTP_CODE_OK) {
			String payload = http.getString();
			Serial.println(payload);
		}
	} else {
		LOGf("POST... failed, error: %s\n", http.errorToString(httpCode).c_str());
	}
	http.end();
}

Debug Messages:

[Fn:face_add        :230 ]:http begin...
[Fn:face_add        :248 ]:POST... failed, error: send payload failed 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleIssue is stale stage (outdated/stuck)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions