Greetings everybody!
Another day another another bug
I have to sets of picture to be uploaded to google drive with the use of app script.
Group 1 group 2
The app script :
- Rename the image
- Add a timestamp
- Add a text.
I use a key as to secure the connection.
To send the picture I use the KIO4_BASE64.
I need to add a text "Before" to the group 1 and "After" to group 2.
It is defined in the app script but can not define the latter in app inventor as the block .GotString
can be used once only.
You can see my blocks here:
and here is my code :
function doGet(e) {
var name = e.parameter.name;
var mimetype = e.parameter.mimetype;
var data = e.parameter.data;
var Aname = "After_" + name + ", status " + Utilities.formatDate(new Date(), "GMT+4", " "HH:mm:ss");
var Bname = "Before_" +name + ", status" + Utilities.formatDate(new Date(), "GMT+4", "HH:mm:ss");
if(Hkey == "12345"){
var data = Utilities.base64Decode(data);
var blob = Utilities.newBlob(data, mimetype, Bname);
DriveApp.getFolderById('xxxxxxxxxxxxxxxxxxxxxxx').createFile(blob);
}
if(Hkey=="67890"){
var data = Utilities.base64Decode(data);
var blob = Utilities.newBlob(data, mimetype, Aname);
DriveApp.getFolderById('xxxxxxxxxxxxxxxxxxxxxxx').createFile(blob);
}
return ContentService.createTextOutput("Picture of"+name+" uploaded.");
}