- ESP32-CAM capture image and update that image in Google Drive (II).
We are going to change the Script code, we will use part of the @TIMAI2 code to update the image that we will call capture.jpg
function doPost(e) {
var data = Utilities.base64Decode(e.parameters.data);
// var nombreArchivo = Utilities.formatDate(new Date(), "GMT-3", "yyyyMMdd_HHmmss")+".jpg";
var filename = "capture.jpg";
var blob = Utilities.newBlob(data, e.parameters.mimetype, filename);
var folder, folders = DriveApp.getFoldersByName("ESP32-CAM");
if (folders.hasNext()) {
folder = folders.next();
} else {
folder = DriveApp.createFolder("ESP32-CAM");
}
var existing = folder.getFilesByName(filename);
if (existing.hasNext()) {
var file = existing.next();
if (file.getName() == filename) {
fileID = file.getId();
// Drive.Files.update({title: filename, mimeType: mimetype}, fileID, blob);
Drive.Files.update({title: filename, mimeType: file.getMimeType()}, fileID, blob);
}
} else {
blob = Utilities.newBlob(data, e.parameters.mimetype, filename);
fileID = folder.createFile(blob).getId();
}
// var file = folder.createFile(blob);
return ContentService.createTextOutput("Completo.")
}
- We can locate the key of the file and put it in an Image component within a Clock, every certain interval the image will be updated on the screen.

