Friday, September 13, 2013

Random: Linking Directly to Google Docs to Download Files with a Click

A FYI for how to link your Google docs so that someone clicking the link would download the file instead of opening the file in Google Docs (the default). Note that this works only for files not in the native Google Docs format - files like PDFs or DOCXs.
Step 1: Find the File ID, which you can do by sharing your file normally. For example, the File ID here is: 0B_drXJmgtDreSjhhSmo1R3N6Tms, which I get from the share link:
https://docs.google.com/file/d/0B_drXJmgtDreSjhhSmo1R3N6Tms/edit?usp=sharing
clip_image001
Step 2: Use the following URL and replace the text "FILEID" with your actual file ID.
https://docs.google.com/uc?export=download&id=FILEID .
In my example, the link would be: https://docs.google.com/uc?export=download&id=0B_drXJmgtDreSjhhSmo1R3N6Tms

That is it.

Aside #1: To make any files (well, by any, I mean files supported by Google docs - PDF, DOC, etc.) on the web viewable, you can use the following bookmarklet code. I still find doing this convenient and useful. Basically, after setting it up, you can click the bookmarklet, and then click on any file URLs to have Google Docs on it in your browser. For my slow computer, this works quicker than using Word or PDF-XChange to open the files. Note the code basically looks for filetypes that Google Docs support, and add a prefix in front of the link.

The code:
javascript:var%20link,l=0;while(link=document.links[l++]){if(link.href.toLowerCase().indexOf('.xls')!=-1|link.href.toLowerCase().indexOf('.xlsx')!=-1|link.href.toLowerCase().indexOf('.ppt')!=-1|link.href.toLowerCase().indexOf('.pptx')!=-1|link.href.toLowerCase().indexOf('.doc')!=-1|link.href.toLowerCase().indexOf('.ps')!=-1|link.href.toLowerCase().indexOf('.xps')!=-1|link.href.toLowerCase().indexOf('.pdf')!=-1|link.href.toLowerCase().indexOf('.pages')!=-1|link.href.toLowerCase().indexOf('.ai')!=-1|link.href.toLowerCase().indexOf('.psd')!=-1|link.href.toLowerCase().indexOf('.dxf')!=-1|link.href.toLowerCase().indexOf('.svg')!=-1|link.href.toLowerCase().indexOf('.tiff')!=-1|link.href.toLowerCase().indexOf('.tif')!=-1&&link.href.indexOf('javascript')==-1&&link.href.indexOf('file:')==-1){var%20newString='http://docs.google.com/viewer?url='+link.href;link.href=newString;}};void(null);


The snapshot of my bookmarklet property dialog box:
image

Aside #2: I was hoping Google Drive can replicate the function of Dropbox's public folder. That was the reason I am looking for a way to open files from Google docs directly. This does *not* work in the way Dropbox's public folder does. In Dropbox, setting up the URL allows anyone to download the file I have in my public folder. And if I update that file, the link will link to the new files. (Because my upload gets sync to the Dropbox service, and that's really where the URL links.)


Reference: http://thebiobucket.blogspot.com/2011/10/how-to-link-to-google-docs-for-download.html