Google Drive: Listing files issue

Hi Anke,

I tested your extension to download any file types to ASD- Version: 4 on Android 9 and Android 13. it worked as expected.

However, I currently type in the URL manually, as of now URL from google drive / onedrive. Is there a way I can get list of files from google drive and let the users pick a file from the list.

which can then be used as URL for DownloadToASD.

Thanks for your time.

Have a good day!

This is a general question, separate from my extension.
(→ Google search... There are countless posts, tutorials, videos about it.)

Make a Google Apps Script Web App, and feed it a folder ID

// return list of files in a folder
function doGet(e) {
  filesList=[];
  var parentFolder = DriveApp.getFolderById(e.parameter.folderID);
  var files = parentFolder.getFiles();
  while (files.hasNext()) {
    var file = files.next();
    filesList.push([file.getName(),file.getId()]);
  }
  var output = JSON.stringify(filesList);
  return ContentService.createTextOutput( output );
}

Use a listview or listpicker

1 Like

Thanks for your response. I'll work on that.

Thanks for your response.

Hi @TIMAI2

I have incorporated the file list to the app. i.e. a webviewer to display the link to download which works when gdrive URL is a public link.

I want to know how the webviewer can be associated to the current user's google account so that even private download URL will work as expected.

Kindly suggest how webviewer can be linked to the current google account so when download URL is tapped it will download the file.

Thanks!!
webviewer-output
Again

Just to give a background on the requirement,

Scenario is user will pick a text file from their google drive that will be downloaded / copied to application specific directory (ASD).
This file in ASD will be used by the app for further processing and publishing output.

Hope my requirement is clear.

Thanks!

Just to clarify, you want the google apps script to run on the users own google drive, in order to return files on their google drive?

Yes I have set the deployment accordingly I.e excuted "as user accessing" the web app.

  1. You need to modify the user agent of the webviewer to allow google authentication when the user signs in / authenticates the web app. You can do this using the webviewextra extension, or the webviewtools extension, or the CustomWebView extension.
  2. As indicated above, the user must sign in to their google account through the webviewer, and also authenticate / allow the web app to have access to their google drive. You will also need to perform all actions through the webviewer, you won't be able to use the web component.
  3. You can use the webviewstring to exchange "strings" between the app and the webviewer, if needed.

Thanks @TIMAI2 I'll try the mentioned extensions.

You may also find this useful:

(written before Juan and I came up with the webviewextra extension)

webviewextra extension worked as expected to download the chosen file to /Download folder and then used File component to copy it to ASD.

The only drawback is user login on the webviewer as you also pointed out.

If this is overcome it would be perfect.

I found GDConnector little overwhelming due to its loaded features.

If you come across workaround to avoid google login in webviewer, please let me know.

Thanks a lot!!!
Thanks

You can use this extension, this extension makes your work easy ↓

Yes, but there are other methods that are free and relatively easy, using Google Apps Script. The user also wants other users to authenticate their own folders.

Have you tried authenticating a user (not the script owner) with the web app through the webviewer (with webviewextra in place) ?

GD Connector was really intended to show you the authentication mechanism.

I think it won't be a free solution then.

GDrive extension does not use webviewer for authentication. Instead Google Auth flow is used.
All the features you need are available in the extension.

2 Likes

Thanks! will check if it fits my current requirement.

Yes, it works for different logins as well and caches the information for subsequent use or until the app cache is cleared.

GD Connector comes with spreadsheet and I felt it would be an overkill for my current simple requirement. Also, I couldn't get the blocks for my current flow requirement quickly due to lack of example.
If you can list the blocks I need for my current requirement, I'll check it out and let you know how it went.

Thanks!

Sure @vknow360 I'll check the GDrive details and let you know.

Thanks!!