Mount Google Drive for Remote Image Storage

Mount Google Drive, then share it out to your website

I’m running out of space on my really cheap web hosting provider. So I’m moving all of my images to Google Drive. Here’s how to mount Google Drive, and be able to share those images out on a website.


August 28, 2019

Too Many Images

I’ve been thinking of hosting all of FossFolks.com’s images on Google Drive for a while. I’ve been wanting to have my images up there, then call them from the site. But I don’t like web interfaces. I’d rather mount Google Drive so that it shows up as a local directory.

NoSupportLinuxHosting.com currently hosts Fossfolks.com. It costs a buck a month, and how can you beat that? It’s been fine, but there are no backups. I found that out when another blog of mine went belly up (NSLH’s server went down) and while I was upset, “no backups” is right there in their readme/policy docs. It was all my fault.

So I can make regular backups whenever I create new content. There’s a pretty small limit on disk usage too though, so one of the things I’m in the midst of is getting all of my images in Google Drive (more than enough space, and free) then calling them remotely. I’m guessing some of other folks are in the same boat, so here’s how I’m doing it…

How to Mount Google Drive

First off, we’ve got to install some software, and it’s sitting in a repository that Ubuntu users don’t have access to by default. Add it with this:

sudo add-apt-repository ppa:alessandro-strada/ppa
sudo apt-get update

Then we can actually install the software with this:

sudo apt-get install google-drive-ocamlfuse

Then, to get it mounted locally, we’ve got to make a place for it, and do the actual mounting:

mkdir google_drive
google-drive-ocamlfuse ~/google_drive

Sharing out Images from Google Drive

Great. We can mount Google Drive, but now what? Well, I’ll tell you. We can push images up to it from our local computer, and then call them from our website. I have never liked WordPress’s image process (I don’t want them stored by date — I want them stored by blog post category!) so now I can just put a little bit of a different image tag by hand into my blog posts.

First, I’ve got to get the “shareable link” from Google drive.

But the link Google gives doesn’t quite work. If we go get a shareable link, they’re going to give us something like:

https://drive.google.com/file/d/15LHMAKGh9ZsJiaElrtgg6c6PumSvRC6Q/view?usp=sharing

What we actually need for that image is this:

<img src="https://drive.google.com/uc?export=view&id=15LHMAKGh9ZsJiaElrtgg6c6PumSvRC6Q" />

And that translates into this:

Mount Google Drive, then share it out to your website

That’s pretty much it. Using this method, all your images can be sitting up in a free Google Drive account, and you’re able to mount Google Drive like it’s a local disk, then just get each image’s ID and plug it into a website.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.