Transparently download from Google Drive

Please note that this blog has been moved.

Now it has its own domain: 🙂

If you want to read the latest version of this article (recommended) please click here and I open the page for you.

Google Drive is a file storage and synchronization service provided by Google which enables user cloud storage, file sharing and collaborative editing.

The storage limit for the free accounts is, at the time of writing, about 5GB.

If you have a blog, like I have, and sometimes you write an article and you want to share a files rather than inserting its contents into the articles page, you could use your free Google account and the Google Drive service to store and share that file.

The problem

The problem that I have encountered regarding this matter was that, when sharing a file you get a public share link, like the one below:

If you provide this address as your HTML link reference then you will not be prompted by the “Save as” window, instead the Google Drive Viewer application will be shown and this will allow you, of course, to download that file:

click to zoom

a file shown in Google Drive Viewer

As we can see in the link provided above, it is structured as following:


  • the secure connection protocol : https
  • the (sub)domain name :
  • other application/directories within the Google website : file/d/
  • the file unique identifier : 0B95k2kr1bG9feGVhd0p3QkVCSVE
  • the action/command to execute about that file: view (or edit, etc)

If I would write an article and I wish to insert a link to a shared file (stored on Google Drive) I would not be happy to let my readers/visitors to open the Google Drive Viewer then to put them to click one more time, and so on. What I would like to achieve would be to get directly that Save as windows:

click to zoom

the “Save As” window when clicking on a file link

Obviously there are (at least) two types of downloads where you really need the direct download link:

  1. nice to have: on a link inserted on a HTML page (such as a article)
  2. must to have: on a link where you are supposed to download the file programmatically

In the first case you could live even without the direct link, maybe the Google Drive Viewer it’s not such a big deal at the end.

In the second case, if you don’t have a direct link, you could end downloading a content which is not your file but the Google Drive Viewer html content for the requested file:

<!DOCTYPE html><html><head><meta name="google" content="notranslate">
<meta http-equiv="X-UA-Compatible" content="IE=edge;">
<meta name="fragment" content="!"><title>.config.rpi $
c&&0<b&&(c.tick("_tbnd",void 0,,

My solution(s)

Obviously, by trial an error, I found solutions for both cases.

  1. For the link you would insert into your web page (such as a article) you could use the following pattern:
  1. For the link where you are supposed to download the file programmatically the pattern above will not work, instead you will get an error message like below:
root@rpi-gentoo ~ $ --2013-02-23 10:33:32--
Resolving,,, ...
Connecting to||:443... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2013-02-23 10:33:32 ERROR 500: Internal Server Error.

I’ve found that the following pattern will work like a charm:


Note that in the second case (the one above) the file name you will be prompted to save (programmatically or not) will not be the original shared file name (like in the first example) but the file hashed identifier (such as 0B95k2kr1bG9feGVhd0p3QkVCSVE). Since this method provides a direct link (by the file-id) to download the file programmatically (eg: wget -O <output-file> URL), it would not be a challenge for any programmer to choose whatever name he/she likes for the output-file.

About Eugen Mihailescu

Always looking to learn more about *nix world, about the fundamental concepts of arithmetic, algebra and geometry. I am also passionate about programming, database and systems administration.
This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink.

13 Responses to Transparently download from Google Drive

  1. t says:

    Thanks for this man, really saved my bacon. Wish google would just tell us how to do these stuff so we don’t have to have all the pain finding out little hacks like this, and then google can just change it whenever they want and just break it…

    well anyway thanks man, also confirming that it still works now.

  2. sandro says:

    Thank you it works!

  3. sandro says:

    I think this method no longer works 😦 I get 403 error

    • If you will try the sample download link that I have mentioned in this article you will see that they are still working. Perhaps you have tested your own links (files) and they are either not shared or you have used a wrong file-id. I have no idea what is wrong with your test.

  4. cicevicek says:

    I think this works as long as the file “does not exceed the maximum size that Google can scan”. For larger files this method gets the html page with that info.

  5. Hi there, when i try to wget a file from my google drive using my rpi, i get the following message:

    wget: not an http or ftp url:

    Have google changed something since your article published or is this something in my rpi not working or have i missed something?

    • Hi Nathan!

      I think that the file-id you’ve mentioned (14Tjjz_bIQOZywNIXcQfGSJUZVl0LWOj94PZfKsvbHs0) it’s the problem. Check again how did you get that file-id, obviously it’s not that it should be.
      Check out again My Solution(s) section above. It shows you exactly what you have to do. I actually double-checked that those links on “My solutions” section are (still) working as described and they do.

  6. Gigi Duru says:

    Thanks for sharing this, I created this url witch works fine in browser but if I try with wget:
    # wget -c -O minidlna.conf
    wget: not an http or ftp url:

    • Oh, I’ve just downloaded yours .conf file with exactly the same command and it works like a charm!
      So the problem is not the command itself but your proxy, your Internet connection, wget version that you might have installed, etc.
      Anyway thanks for sharing your feedback.

      • Gigi Duru says:

        You are right, just tried on ubuntu and it works but I need it on my router with entware.
        Thanks for pointing me to the right direction

  7. Chris Trude says:

    This works great still, thank you for the solution, I have 2 advanced questions though:

    1. This works for me for .gz files but then I can’t seem to ungzip them properly. Any ideas?
    2. How would this work for whole folders? If I can’t get the gz to work, I want to just upload/download the whole folder of content. Any ideas?


    • Note that I’m not using this blog anymore (the old blog got its own domain, so it’s relocated at This is important because the mentioned post might get some updates/similar comments. The respective post can be found at:

      (1) I don’t know exactly how you download the file. Probably it’s not .gz anymore, probably it’s just a HTML with some content from Google. Have you checked its content? (with a text editor or something)

      (2) You can share a google drive but I don’t think that you can download a folder together with all its content because it’s not a file. If the Google would provide a functionality such that a folder would have a direct link to its zipped content then of course, you would be able to download that archive thus the folder content. So as far as I know only the files are download-able. Using a programming language (eg. PHP) you would be able to connect the Google Drive, to fetch a list of file/folder and then to proceed accordingly.

      PS: don’t respond to this comment here, on blog, I will not answer anymore. Not here 😉

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s