How to Host Images using Google Drive

Updated onbyAlan Morel
How to Host Images using Google Drive

In this post, we'll learn how to host images on Google Drive. From there you can create public links to your images, which can be shared with anyone or embedded on your website.

Google Drive is a great hosting service because it is widely available and free. We're going to use Google Drive to create a public image URL to this image:

The cat image we will host on Google Drive

Hosting images on Google Drive

To begin, make sure you have a Google account. From here, access your Google Drive.

From here, hit the New button and upload an image to Google Drive.

The New button in Google Drive

After you upload the image, locate the file, click on it, then hit Get Link.

The Get Link button in Google Drive

From here, set the file to public by setting the visibility to Anyone with the link. Copy the link and hit Done.

You should get something like this:

BASH
https://drive.google.com/file/d/1lD76TcHP3p2yLCp6gzGqnB3meoDHKpuK/view?usp=sharing

With the link above, you'll need to get the image's unique ID. You can get the image's ID by copying everything after https://drive.google.com/file/d/ and before /view?usp=sharing.

The structure of the link above is:

BASH
https://drive.google.com/file/d/{UNIQUE_ID}/view?usp=sharing

The unique ID of our image is:

BASH
1lD76TcHP3p2yLCp6gzGqnB3meoDHKpuK

From there, we can now create a public link to our image by following the below structure:

BASH
https://drive.google.com/uc?id={UNIQUE_ID}

Just replace {UNIQUE_ID} with the unique ID of our image.

BASH
https://drive.google.com/uc?id=1lD76TcHP3p2yLCp6gzGqnB3meoDHKpuK

And that's it! If you visit that link, you should see your image being served by Google Drive.

The cat image we hosted on Google Drive

Then, you can embed it on your website, like so:

HTML
<img src="https://drive.google.com/uc?id=1lD76TcHP3p2yLCp6gzGqnB3meoDHKpuK" alt="My image on Google Drive" />

Conclusion

We've seen how you can use Google Drive to create public URLs to images, essentially using Google Drive as your own image hosting service.

Hopefully, you've found this post helpful in case you want to host images on Google Drive yourself.

Thanks for reading!

To learn more about web development, founding a start-up, and bootstrapping a SaaS, follow me on X!
Copyright © 2017 - 2024 Sabe.io. All rights reserved. Made with ❤ in NY.