Add a menu to Google Drive

2019-08-06 17:03发布

问题:

I'm working on a project where my requirement is, when I share a file/folder to someone from Google Drive I should be able to attach a date to it, and once the date has passed they should not be able to view the file/folder.

When I was searching I stumbled upon http://ctrlq.org/code/19376-change-folder-permissions-google-script

My questions: Is there a way I can activate this script on Google Drive itself, i.e. When a file is checked, I need a menu item saying 'Sharing Expires On' under the more options menu, and I should be able to add a date to it.

Please guide me through this.

回答1:

Yes, it's quite new and advanced (and neat) but in a nutshell you would:

  1. Write an Apps Script using DriveApp and publish it as a web app.
  2. Setup a new Drive SDK project on the developers console and point an Open URL action to the url from 1. This allows you to extend the context menu with your own "Expiring share" style option for a selected file(s).

There is a fantastic Google I/O 2013 session that covers this entire process: Google I/O 2013 - Integrate Google Drive with Google Apps Script. When you watch it you'll see it starts out with a demo. The technical details diving into the above steps starts at 13:10.