ESP32 - How to send a file stored on SD drive via FTP

I would like to take pictures using an ESP32-CAM, store them on an SD card and, once a day, post them to Google Drive or FTP.

I can already post pictures as soon they are taken but once stored on a SD card I need to read them back to a memory variable and that is where things are not working.

The idea of this function is to post the first image found and them delete it.
Code of the function as below:

void postPicture(fs::FS &fs, const char * dirname){
 Serial.printf("Listing directory: %s\n", dirname);

 File root = fs.open(dirname);
 if(!root){
   Serial.println("Failed to open directory");
   return;
 }
 if(!root.isDirectory()){
   Serial.println("Not a directory");
   return;
 }

 File file = root.openNextFile();
 while(file){
   if(file.size()>0){
     Serial.print("  FILE: ");
     Serial.print(file.name());
     Serial.print("  SIZE: ");
     Serial.println(file.size());

     uint8_t* buf[file.size()];
     file.read(buf,file.size());  <---------------------ERROR as below
     
     //some more code goes here...

     deleteFile(SD_MMC,file.name());
     break;
   }
     file = root.openNextFile();
 }
}

Error message is:
exit status 1
no matching function for call to 'fs::File::read(uint8_t* [( + 1)], size_t)'

Thanks

1 Like

Solved with:

      String imageBuffer;
      while (file.available()){
        imageBuffer += char(file.read());
      }
1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.