Friday, 24 January 2020

How to Get Direct View/Download Link for a Google Drive File

Google Drive let users store files online. When click 'Get Shareable Link' on context menu, an URL is copied to clipboard for pasting, it is always:

https://drive.google.com/open?id=XXX

This link opens the View UI of Google Drive for the file, however, sometimes we need the direct link to images to show on web page, or direct link to trigger download immediately, here it is, just change "/open" to "/uc" where 'uc' means 'user content':

https://drive.google.com/uc?id=XXX

Note that the 'uc' link always trigger download or show in web pages if it is UC of images, as Google doesn't want to have Google Drive turned into web hosting. So, if the UC link is a link to .html file, instead of showing the web contents, it forces you to download with this HTTP response header:

Content-Disposition: attachment;

No comments:

Post a Comment