Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically Download Content from Drive Share Links

I'm building an application to automatically trigger a download of a file share with a user. For example, this was straight forward to implement for Dropbox links, as is outlined here.

I'm trying to implement the same functionality for Google Drive links, but running into difficulties. Right now the app takes the third part of the link (the file ID) and appends it to "https://docs.google.com/uc?export=download&id= ". But this seems unreliable, especially as there are at least 3 different link formats for shared files that I've found (https://drive.google.com/file/d/xyz, https://docs.google.com/document/d/xyz etc.). Does anyone know of a generally applicable and reliable way to grab the files from Google Drive shared links, like the process outlined for Dropbox above?

Finally, we have Oauth access to a users Drive account. For files shared with them that have sharing settings set to 'Private' (or anything other than 'Public on the web' or 'Anyone with the link'), I've been researching (with little success) if it is possible to download those files on behalf of the Oauth authenticated user - does anyone have any insight on this?

Any insight/suggestions would be greatly appreciated.

[Update] The "private" shared files can be downloaded from the users Drive account - they're automatically added to the 'Shared with me folder', so just need a reliable way to grab the file ID.

like image 515
Cian Avatar asked Nov 26 '13 16:11

Cian


People also ask

Can people with Google Drive link download files?

Anyone can search for, find, and download the file. On (Link): Anyone with the link can download it. They don't have to sign in to their Google account to do so.


1 Answers

From my understanding of drive, you need to look in separate places for different file types:

  • /document/: Documents
  • /presentation/: Presentations
  • /spreadsheet/: Spreadsheets
  • /forms/: Forms
  • /drawings/: Drawings

Other than that, there doesn't seem to be a way to retrieve the documents.

like image 154
Msmith Avatar answered Oct 17 '22 07:10

Msmith