nhatuan84 / esp32-upload-download-multipart-http

This library supports upload multipart and download file via http
25 stars 19 forks source link

Unable to upload file from ESP32 to server #4

Open sid548 opened 4 years ago

sid548 commented 4 years ago

I am trying to upload file from ESP32 to a cloud server. Using your code, and using the given below mentioned stack, but unable to send the files. In fact in the server logs, I don't see any request coming from the ESP32 as well. My API is well tested in Postman and is working fine. Can you please help ??

`#include "/home/sidharth/Desktop/IoT/esp32udhttp/UDHttp.h"

include "SD.h"

const char ssid = "my ssid"; const char password = "my password";

File root; //these callbacks will be invoked to read and write data to sdcard //and process response //and showing progress int responsef(uint8_t *buffer, int len){ Serial.printf("%s\n", buffer); return 0; }

int rdataf(uint8_t *buffer, int len){ //read file to upload if (root.available()) { return root.read(buffer, len); } return 0; }

int wdataf(uint8_t *buffer, int len){ //write downloaded data to file return root.write(buffer, len); }

void progressf(int percent){ Serial.printf("%d\n", percent); }

void setup() { // put your setup code here, to run once: Serial.begin(115200);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }

Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP());

Serial.print("Initializing SD card..."); if (!SD.begin()) { Serial.println("initialization failed!"); return; } Serial.println("initialization done.");

{ UDHttp udh; //open file on sdcard to read root = SD.open("/data.csv"); if (!root) { Serial.println("can not open file!"); return; } //upload downloaded file to local server udh.upload(url handler, "data.csv", root.size(), rdataf, progressf, responsef); root.close(); Serial.printf("done uploading\n"); } }

void loop() { // put your main code here, to run repeatedly:

}`

and here is the output

`rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1216 ho 0 tail 12 room 4 load:0x40078000,len:9720 ho 0 tail 12 room 4 load:0x40080400,len:6352 entry 0x400806b8 . WiFi connected Initializing SD card...initialization done. 0 done uploading

`