What would also work? Please explain exactly what it is you are trying to do...
Okay so what we it I had in mind was a companion typed in the link of its drive image and hits enter
Now what it does is that it takes the link of the textbox and turns that into a image and puts it in the image componen. Lastly a tinyDB is used to save the image it previously used
That is a difficult method for the user to follow, fraught with the opportunity for typing errors.
Provide the use with a list of filenames (perhaps even with thumbnails) to select from, then on selection the required image is fetched from google drive for display.
Where do these images come from, how do this images get onto google drive, how do you get the file id information back into the app?
There is the opportunity to use a google apps script that will create a table in a google sheet of filenames and file ids, which your app could download:
See HERE
and HERE
I don't get this code can you show me how it is done
It is all here
Wells its all in code but its not in block code and could hardly get it
Google Apps Script is not written in AppInventor blocks, which is why i provided the link for how to setup an apps script web app.
Can you go over the code and see if I did it correctly
function listbyNameFoldersAndSubFoldersContents() {
var ss = SpreadsheetApp.getActive();
var sheet = ss.getActiveSheet();
sheet.clear();
sheet.appendRow( ['Filename', 'Type', 'ID', 'DD URL'] );
var myFolder = Browser.inputBox('Enter your folder name');
var folders = DriveApp.getFoldersByName(myFolder);
var folder = folders.next();
traverseFolders(folder, folder.getName());
}
function traverseFolders(folder, path) {
var sheet = SpreadsheetApp.getActiveSheet();
var files = folder.getFiles(), file, fileName;
while (files.hasNext())
{
file = files.next();
fileName = file.getName();
sheet.appendRow([fileName, niceFileType(file.getMimeType()), file.getId(), "https://docs.google.com/uc?export=download&confirm=no_antivirus&id=" +file.getId()]);
}
var folders = folder.getFolders(), childFolder;
while (folders.hasNext())
{
childFolder = folders.next();
traverseFolders(childFolder, path + ", " + childFolder.getName());
}
}
function niceFileType( mimeType ) {
if (typeof this.fileType === 'undefined') {
this.fileType = {};
this.fileType[MimeType.FOLDER] = "Folder";
this.fileType[MimeType.GOOGLE_APPS_SCRIPT] = "Google Apps Script";
this.fileType[MimeType.GOOGLE_DOCS] = "Google Doc";
this.fileType[MimeType.GOOGLE_DRAWINGS] = "Google Drawing";
this.fileType[MimeType.GOOGLE_FORMS] = "Google Form";
this.fileType[MimeType.GOOGLE_SHEETS] = "Google Sheet";
this.fileType[MimeType.GOOGLE_SLIDES] = "Google Slides";
this.fileType[MimeType.JPEG] = "JPG";
this.fileType[MimeType.PNG] = "PNG";
this.fileType[MimeType.BMP] = "BMP";
this.fileType[MimeType.GIF] = "GIF";
this.fileType[MimeType.SVG] = "SVG";
this.fileType[MimeType.PDF] = "PDF";
this.fileType[MimeType.CSV] = "CSV";
}
return (this.fileType.hasOwnProperty(mimeType)) ? this.fileType[mimeType] : "UNKNOWN";
}
I know it says it on the website you showed me but it didn't tell me where to start the code
You can just run that script from your spreadsheet, but if you want to fully automate in conjunction with your AppInventor app then you will probably want a web app, to call the function.
Can you tell me how to do it
I have a busy weekend ahead, but when i get some time, I will work up an example.
Okay I can be patient and wait till you come back
Well, it didn't actually take all that long:
Drive Folder with Images
Google Apps Script Web App
function doGet(e) {
var ss = SpreadsheetApp.getActive();
var sheet = ss.getActiveSheet();
sheet.clear();
sheet.appendRow( ['Filename', 'FileType', 'FileID', 'ViewUrl'] );
var folderId = '1EjhZxyuFy_edited_wkS--QdpauABaMpU';
var folder = DriveApp.getFolderById(folderId);
var contents = folder.getFiles();
var file, name, id, url, type;
while(contents.hasNext()) {
file = contents.next();
name = file.getName();
id = file.getId();
url = "https://lh3.googleusercontent.com/d/" +file.getId();
type = niceFileType(file.getMimeType());
sheet.appendRow( [name,type,id,url] );
}
SpreadsheetApp.flush();
rng = sheet.getDataRange().getValues();
return ContentService.createTextOutput(JSON.stringify(rng));
}
function niceFileType( mimeType ) {
if (typeof this.fileType === 'undefined') {
this.fileType = {};
this.fileType[MimeType.FOLDER] = "Folder";
this.fileType[MimeType.GOOGLE_APPS_SCRIPT] = "Google Apps Script";
this.fileType[MimeType.GOOGLE_DOCS] = "Google Doc";
this.fileType[MimeType.GOOGLE_DRAWINGS] = "Google Drawing";
this.fileType[MimeType.GOOGLE_FORMS] = "Google Form";
this.fileType[MimeType.GOOGLE_SHEETS] = "Google Sheet";
this.fileType[MimeType.GOOGLE_SLIDES] = "Google Slides";
this.fileType[MimeType.JPEG] = "JPG";
this.fileType[MimeType.PNG] = "PNG";
this.fileType[MimeType.BMP] = "BMP";
this.fileType[MimeType.GIF] = "GIF";
this.fileType[MimeType.SVG] = "SVG";
this.fileType[MimeType.PDF] = "PDF";
this.fileType[MimeType.CSV] = "CSV";
}
return (this.fileType.hasOwnProperty(mimeType)) ? this.fileType[mimeType] : "UNKNOWN";
}
Blocks (updated to call thumbnails)
Spreadsheet with Data
App Screenshot
note: the image folder is set to anyone with the link (as are the files inside). The spreadsheet can either be restricted or anyone with the link.
You might also be interrested in this approach...
Is it like the person would have a folder in google drive that they could put there PDF Pictures in it that would transmit to mit app inventor
Images, not PDFs.
How do you send the clip as a script link or something for the Web1 Url
You know the code in Apps Scripting how do I send the code to app inventor
You get the script url when you deploy the web app in Google Apps Script.