Direct Link to Google Drive

Previously I blogged about gdURL.com and how you can use it to make direct links to files in Google Drive. This is useful, if for example, your PDF file you want to link to doesn’t display as well in the Google Document viewer. Using gdURL.com to make a direct link fixes this, as you link directly to the file and not viewing it through the Google Document Viewer. But even using gdURL.com poses problems as you are trusting a third party to make the links, etc for you. So let’s take a look at making those direct links ourselves, that go straight to Google and not through a third party.

First we need to generate the shared link to the file in Google Drive. Open the file and click the Share Button, then change settings to Anyone with the link. You will also see at the top the long URL to link to this document. Copy it as we will need it later, but this link will open the file in the Google Document Viewer. The link should look something like the one below.

https://drive.google.com/file/d/0BxQQH6yP0VuVelRGaFRuVHgxXzA/edit?usp=sharing

In this long link there is what is called the Unique ID. That is the part we need to copy, so for the link in the example it would be the part in bold, or 0BxQQH6yP0VuVelRGaFRuVHgxXzA.

To generate a direct link we just use the following URL,

https://docs.google.com/uc?export=view&id=UNIQUEID

And replace the word UNIQUEID with the unique ID from the actual shared Google Drive URL, so the final product would look like this.

https://docs.google.com/uc?export=view&id=0BxQQH6yP0VuVelRGaFRuVHgxXzA

Now if you want to take this a step further, using a similar method you can generate a direct link to Google Drive for a file, and have it do a download as opposed to viewing it. To do this we just use the same method, but in our url we change the word VIEW to DOWNLOAD and replace the unique ID with the one from your Google Drive share url. So it would look something like this.

https://docs.google.com/uc?export=download&id=0BxQQH6yP0VuVelRGaFRuVHgxXzA

Of course this method only works linking to actual files in Google Drive, such as JPGs, PDFs, etc. Linking to a Google Doc will not work as that needs to be viewed in the Google Document Viewer. So if you find yourself needing to direct link a PDF from Google Drive to a website, try this method as it seems to work pretty well.