DarreeN
DarreeN

Reputation: 21

ESP32 Upload a flash memory file to Google Drive using a program for ESP32CAM

I am trying to upload a ".wav" (circa 32kB) file from the flash memory of ESP32 to Google Drive. Is there a way to do that and would you be able to suggest a way to approach this? I am currently trying to use a code that does the same thing, but with ESP-cam images, and the encoding is very confusing.

The way this code works like:

  1. Take an ESP camera structure called "fb" which includes an image (I am not able to figure out the specific way it is structured).
  2. Convert the image in the "fb" structure into a "data" string. This is shown in the code below.
  3. Send in the necessary information using "client.prinln" before sending the encoded image (as "data") using the "for" loop at the end of the code.

What I am trying to do:

I am desperately trying to replace the "fb" structure with a file created by SPIFFS.open(). The image in the code below is taken from the structure in the first two lines of the code, I struggle to understand this part the most.

Thank you for any help!

Source: Upload an image directly from ESP32-CAM to Google Driv

char *input = (char *)fb->buf;
char output[base64_enc_len(3)];
String imageFile = "";
for (int i=0;i<fb->len;i++) {
  base64_encode(output, (input++), 3);
  if (i%3==0) imageFile += urlencode(String(output));
}
String Data = myFilename+mimeType+myImage;

esp_camera_fb_return(fb);

Serial.println("Send a captured image to Google Drive.");

client.println("POST " + myScript + " HTTP/1.1");
client.println("Host: " + String(myDomain));
client.println("Content-Length: " + String(Data.length()+imageFile.length()));
client.println("Content-Type: application/x-www-form-urlencoded");
client.println();

client.print(Data);
int Index;
for (Index = 0; Index < imageFile.length(); Index = Index+1000) {
  client.print(imageFile.substring(Index, Index+1000));
}

Upvotes: 1

Views: 1237

Answers (0)

Related Questions