DEV Community

Cover image for Host images via Google Drive
Chris Bongers
Chris Bongers

Posted on • Originally published at daily-dev-tips.com

Host images via Google Drive

The other day I was playing around with some image effects and needed a place to serve them from an online place.

Don't get me wrong I know there are many tools and websites to do this for you.
Yet I learned that Google Drive can also be one of these options.

As a person who owns unlimited storage, it was worthwhile giving it a go.

Hosting public images on Google Drive

So today I'll be showing you how to host images on Google Drive and have them available for everyone.

Firstly open your Google drive and upload an image.

For this purpose, it doesn't matter if it's in a folder or not.

File uploaded in Google drive

That's part one, now we can click the picture and select the sharing option.

Google drive share button

I changed the option to everyone with the link just to be on the safe side, you'll get a link like this:

https://drive.google.com/file/d/10YD7sJI_HHDXmQM4h96alvyGIU53nGYZ/view?usp=sharing
Enter fullscreen mode Exit fullscreen mode

The part after the /d/ is what we are looking for, as it's the unique ID of the image.

We can copy the unique ID and paste it into the following URL.

https://drive.google.com/uc?id={ID}
Enter fullscreen mode Exit fullscreen mode

So in our case, we get a link like this:

https://drive.google.com/uc?id=10YD7sJI_HHDXmQM4h96alvyGIU53nGYZ
Enter fullscreen mode Exit fullscreen mode

And we are able to use the image as such:

Image of yes I do

And that's it, you're now able to use your Google Drive as a way of hosting images for you.

Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter

Top comments (5)

Collapse
 
harshmangalam profile image
Harsh Mangalam

can i apply more action i.e. delete image programatically and upload programatically

Collapse
 
dailydevtips1 profile image
Chris Bongers

I think that is possible with the actual API, I'll look into writing something on that.

Collapse
 
sturpin profile image
Sergio Turpín

I did'nt know that this could be done, it's very interesting. Thanks for sharing 😉👌

Collapse
 
anand_sourabh_9d93af9428f profile image
Anand Sourabh

Does the id change every time you update the same image with a new image and same title as the previous one? If it does, then it kind of defeats the purpose.

Great idea though!

Collapse
 
dailydevtips1 profile image
Chris Bongers

Well each image will get's a new ID, not sure if you use that update function