1

I am trying to get the public URL of a given file stored in Google Drive. I want to do it for general binary files (ie: no PDFs, TXT, etc., but a general file).

Looking at https://developers.google.com/google-apps/documents-list/#downloading_documents_and_files works to download the file, but I do not want to download. I want to get the public URL to post it somewhere else.

Note that the file is shared at "visible to anyone with link" level (so if I get the link anybody with the link can see it).

I found a hack, using the suggestion from here: Getting the download link for a public Google Docs file.

I build the URL like https://docs.google.com/uc?export=download&id={Insert DocId here}. I get the DocId using the Google Data .NET API.

The thing is that the URL (https://docs.google.com/uc?export=download&id=) is hardcoded in my code. I have been looking in the classes to get the complete URL from the API, instead of building it myself.

BTW: I am using the Google Data API 2.1 http://code.google.com/p/google-gdata

Thanks.

Community
  • 1
  • 1
rufo
  • 5,158
  • 2
  • 36
  • 47
  • Well... I noticed that I probably should be using the new Google Drive API (Google.Apis.Drive..). However, looking for the v2 of that (the samples are for v2, but I haven't found that one in Google's site yet). – rufo Jun 29 '12 at 17:00

1 Answers1

2

You can use the recently released version 2 of the Google Drive API to list the exportLinks of a file stored on Drive:

https://developers.google.com/drive/v2/reference/files

The dlls for the new version of the API will be published very soon on http://code.google.com/p/google-api-dotnet-client/wiki/APIs#Drive_API

Claudio Cherubino
  • 14,896
  • 1
  • 35
  • 42
  • Hi. I am trying to this by the DriveService.Files.List().Items objects have the exportLinks property empty. Everything else is included - I wonder if I need to set an special value in the request object to get it to fill the exportLinks property. – rufo Jul 16 '12 at 22:14