Page 1 of 1

esp32 uploading multipart data to server

Posted: Wed Nov 06, 2019 7:52 am
by pksher
Hi guys I am using esp32 as http client to send multipart data which is basically a jpg file stored in spiffs. I need to send this file to server with the following information.

Host: some url
Content-Type: multipart/form-data
Accept: */*
Content-Disposition: form-data; name="file"; filename="timestamp.jpg"

I am doing this

Code: Select all


file = SPIFFS.open("/timestamp.jpg");
String debugLogData;

  while (file.available()) {
    debugLogData += char(file.read());
  }
  file.close();

  Serial.println("=====================================");
  Serial.println(debugLogData);
  Serial.println("=====================================");


    HTTPClient http;
 
    http.begin("https://id=some url");
   
    http.addHeader("Content-Disposition", "form-data; name=\"file\"; filename=\"timestamp.jpg\"");
    http.addHeader("Content-Type", "multipart/form-data");             
    http.addHeader("Accept", "*/*");
   


    int httpResponseCode = http.POST(debugLogData); 

    http.end(); 




Can anyone suggest something?
Regards,

Re: esp32 uploading multipart data to server

Posted: Thu Nov 07, 2019 9:12 pm
by tommeyers
I suggest you state a problem because it is not clear what you want.

Maybe you want to send a large file via http

Tom