I've noticed that some google drive apps fire POST request to https://docs.google.com/picker/drivepreopen?hostId=myhost upon file selection in picker dialog. Does anybody know what it does?
I need to be able to access my google docs files from my google drive app and I'm aware of the fact that drive apps can access only files it created or opened via context menu in google drive. As the name "drivepreopen" suggests maybe it allows you to programmatically invoke "open with"?
The Picker is how your app should be given access to a file and it can be used to display a list of the currently authenticated user's Drive files, as explained at https://developers.google.com/drive/integrate-open#open_files_using_the_google_picker.
Related
I've created a google apps-script script to create a google document report based on the filtered options in a google sheet. The report generation is started from the google sheet.
I can create the required google document report but would now like to prompt the user to save it to a specific google drive location of their choice using the google drive Move To menu option. When the report is generated, I'd like a prompt to appear stating "Save Report to.." and the user is then displayed the google drive prompt as per this example
and can then select where they want to save it on google drive. Any and all help appreciated.
If the google drive menu options are not integrated, is there another way to prompt the user so they can select which location to store the doc?
Very few built-in user interface menu options are integrated with Google Apps Script, actually most built-in user interface dialogs can't be open by using Google Apps Script but you might use the Google Apps Script HTML service to build your own dialogs.
To help you create your own dialog to handle files in Google Drive you might use Google Picker.
Resources
https://developers.google.com/apps-script/guides/dialogs#file-open_dialogs
Is it possible give a Google App Script permission to create files in a user's Google Drive, and then only have edit/delete access to those files, without having write access to any other files?
From what I can understand, the permission I need for this is drive.file under dependencies.enabledAdvancedServices[].serviceId, which is available in Google Drive API v3, but Google App Scripts only supports v2 (at least, as far as I can tell in the "Advanced Google Services" dialog).
Is there a way to get drive.file in GAS that I'm missing? Or has Google announced any plans to bring v3 into GAS? Or another way to restrict my script to only having write access on files it creates?
If I open the shareable link I have got for a file from Google Drive in the browser, I always get either to the Drive's internal preview program or to a download page (See below).
I would like to know whether there is a programmatic way to launch a specific drive-connected application (with confirmed access permissions) to open a file for which I have the link (and thus, the ID as well).
I don't want to do this through the drive's interface, but rather within my program. Let's say I want to let the users browse their files and open them in the browser with their default app as they have defined it on their drive (and let's say I already know that app).
To make it clear, I just want to achieve what Google Drive's interface does in the browser: You click a file, and it opens in a new tab in your default app.
In my opinion, this is possible with the use of Advanced Drive Service and Drive Service.
Advanced Drive Service
The advanced Drive service allows you to use the Google Drive web API in Apps Script. Much like Apps Script's built-in Drive service, this API allows scripts to create, find, and modify files and folders in Google Drive. In most cases, the built-in service is easier to use, but this advanced service provides a few extra features, including access to custom file properties as well as revisions for files and folders.
and for the Drive Service, you can use getUrl() method to get the URL that can be used to open the File in a Google App like Drive or Docs.
This service allows scripts to create, find, and modify files and folders in Google Drive.
Detailed information and sample codes regarding these services can be found in the documentations.
I am using the Google Drive Realtime API. I can successfully create the doc and have it show up in a user's Drive list. But when they open it, they only hit the Open URL, which routes them to my application. But can I allow them to open the doc with Google Docs instead of coming back to my app?
Its not a google doc, its your own custom format. Google drive wont know how to preview it thus it opens it with your app.
Is it possible to use Google apps scripts deployed as a web app to integrate into the Google Drive UI?
i.e. opening files similar to: https://developers.google.com/drive/about-sdk#create_and_open_files_directly_from_the_drive_ui
But using Google scripts: https://developers.google.com/apps-script/
Scripts do have access to a drive api, but I'm unsure if they have the capability to integrate into the Drive UI?
Yes. You can create a script, deploy it as a web app and call it from the Drive UI as shown in the link you provide. Your script is passed parameter from the Drive UI (including for example, the folder currently selected) and you work from there... I use this mechanism to work with a folder structure representing client activity. Selecting a client folder, I can choose to open with my script or the usual Drive options. My script checks the parameters passed by drive and responds with an appropriate user interface for the next step.