/esp-idf-multipart-upload

A multipart file upload example for esp-idf

Primary LanguageCMIT LicenseMIT

esp-idf-multipart-upload

A multipart file upload example for esp-idf.

Server Side

Download the server from here.


ESP32 Side

Software requirements

ESP-IDF V4.4/V5.x.
ESP-IDF V5.0 is required when using ESP32-C2.
ESP-IDF V5.1 is required when using ESP32-C6.

Installation

git clone https://github.com/nopnop2002/esp-idf-multipart-upload
cd esp-idf-multipart-upload/
idf.py set-target {esp32/esp32s2/esp32s3/esp32c2/esp32c3}
idf.py menuconfig
idf.py flash

Configuration

You have to set this config value with menuconfig.

  • CONFIG_ESP_WIFI_SSID
    SSID of your wifi.
  • CONFIG_ESP_WIFI_PASSWORD
    PASSWORD of your wifi.
  • CONFIG_ESP_MAXIMUM_RETRY
    Maximum number of retries when connecting to wifi.
  • CONFIG_ESP_WEB_SERVER
    IP address or mDNS host name of your WEB Server.
  • CONFIG_ESP_WEB_PORT
    Port number of your WEB Server.
  • CONFIG_ESP_WEB_PATH
    Path of your WEB Server.

menuconfig-1 menuconfig-2

WiFi Setting

menuconfig-3

HTTP Server Setting

menuconfig-4

About multipart/form-data

This example send this HTTP header.
If the parameter expected by the server is not "upfile", you need to change it.

POST PATH HTTP/1.1
HOST: HOST:PORT
User-Agent: esp-idf/X.Y.Z esp32
Accept: */*
Content-Type: multipart/form-data; boundary=X-ESPIDF_MULTIPART
Content-Length: xxx

--X-ESPIDF_MULTIPART
Content-Disposition: form-data; name="upfile"; filename="hoge.jpg"
Content-Type: Content-Type: application/octet-stream

binary-data

--X-ESPIDF_MULTIPART--