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 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:
As we can see in the link provided above, it is structured as following:
- the secure connection protocol : https
- the (sub)domain name : docs.google.com
- 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:
Obviously there are (at least) two types of downloads where you really need the direct download link:
- nice to have: on a link inserted on a HTML page (such as a wordpress.com article)
- 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 by downloading a content which is not your file but the Google Drive Viewer html content for the requested file:
Obviously, by trial an error, I found two solutions to transparently download from Google Drive:
- For the link you would insert into your web page (such as a wordpress.com article) you could use the following pattern:
- 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-- https://docs.google.com/uc?export=download
Resolving docs.google.com... 184.108.40.206, 220.127.116.11, 18.104.22.168, ...
Connecting to docs.google.com|22.214.171.124|: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 URL), it would not be a challenge for any programmer to choose whatever name he/she likes for the output-file.
How to obtain the file-id for the Google Drive file
Open your Google Drive, right-click on your file and then choose Share option. It will open a window like the one below:
The file-id you are looking for is right on the field "Link to share". It is always enclosed between the https://drive.google.com/file/d/ and /edit? parts (eg. 0B95k2kr1bG9faXdzaWNIOGNmSU0).
Now, if you think that this article was interesting don't forget to rate it. It shows me that you care and thus I will continue write about these things.