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