Monday, 31 March 2014

Create Direct Links to your Files on Google Drive

Creating Direct Links to your Files on Google Drive

           You can upload files of virtually all types to your Google Drive – from documents to movies to zip archives – and people with whom you have shared the file can easily view them in the browser itself. The Google Docs web viewer is pretty capable and can render all the popular formats including Photoshop files and AutoCAD drawings.

              That’s a useful feature but sometimes you may want to bypass the built-in Google Docs viewer and force the browser to download the file instead of opening it. Thus if a user has Photoshop on their computer, the PSD file that you have shared through Google Drive will open in Photoshop and not in their web browser.


Create Direct Links and Skip the Web Viewer

 Google Drive doesn’t offer a simple option for creating these “direct download” link but you can easily create them by slightly modifying the generated URLs. Here’s the trick.
A file hosted on Google Drive has a shared link that looks like this:

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

When you access this link, it will render the file in the browser but if you can rewrite this URL slightly, the link, when clicked, will download the corresponding file in the user’s browser instead of opening it in the browser. The modified URL would be:

https://drive.google.com/uc?export=download&id=FILE_ID

All you have to do is make note of the FILE_ID in the original URL and use it in the modified URL. For example, here’s an image file hosted on Google Drive that will open in the browser and here’s the modified URL that forces the browser to download the file.

Direct Download Links for Google Documents...

The trick works for native Google Documents too though the URL format is a little different.
Google Docs: When you share a Google document, the URL would be:

 https://docs.google.com/document/d/FILE_ID/edit?usp=sharing

 
        Replace /edit with /export and add the file format that the document should be saved as and your download link is ready.

https://docs.google.com/document/d/FILE_ID/export?format=doc https://docs.google.com/document/d/FILE_ID/export?format=pdf

        The above links will now download the same Google document in Word (.docx) and PDF formats. You can also use “txt”, “html” and “odt” for the download format.
Google Presentations: Google Docs offer an even simpler URL scheme for creating direct links to Google Presentations.
          The original shared links are of the following format:

https://docs.google.com/presentation/d/FILE_ID/edit?usp=sharing 

         The direct links for downloading the same presentation deck in PowerPoint (.pptx) and PDF formats are below:

https://docs.google.com/presentation/d/FILE_ID/export/pptx https://docs.google.com/presentation/d/FILE_ID/export/pdf 

Google Spreadsheets: 

         Open your Google Spreadsheet in the browser, make the sheet Public (or Anyone with a link) and make a note of the shared URL. It should be something like this:
https://docs.google.com/spreadsheets/d/FILE_ID/edit?usp=sharing The direct download links use a similar format as Google Documents and will read like:
https://docs.google.com/spreadsheets/d/FILE_ID/export?format=xlsx https://docs.google.com/spreadsheets/d/FILE_ID/export?format=pdf

Bonus Trick – Make a Copy

Google Spreadsheets offers an additional feature that is not available in Documents and Presentations (at least yet). You can create links to Google Sheets that will automatically create a copy of your Google Sheet in the Google Drive of the person with whom you have shared the sheet.
 

No comments:

Post a Comment

comment here......