简体   繁体   中英

How can I create a shortcut in Drive that redirects to a specific url

I've been unsuccessfully trying to create a short cut in Drive that once you click on it, you get redirected to a specific url.

Do you have an idea on how I might do that?

Here is the code I started with :

  drive_service = build('drive', 'v2', http=http)

  # Insert a shortcut

  body = {
      'title': 'shortcut',
      'description': 'description',
      'mimetype': 'application/vnd.google-apps.drive-sdk',
  }
  file = drive_service.files().insert(body=body).execute()

It created the file but when I click on it in Drive it redirects me here:

'https://docs.google.com/file/d/{File ID}/edit'

You cant create a shortcut file unless is a custom file that opens by default by your previously-installed drive app.
Else you could create the html for the anchor and use that as the html content for agoogle doc. See the official docs on how to do that, basically you create a new google doc with that html and specify convert=true.
When the user opens the gdoc, she will need two more clicks to navigate to the url.

You control the open location of a shortcut file owned by your app via the Open URL template in the developer console entry.

See these pages on integrating with the Drive UI .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM