How to Host Images using Google Drive
Table of Contents
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:
BASHhttps://drive.google.com/file/d/1lD76TcHP3p2yLCp6gzGqnB3meoDHKpuK/view?usp=sharing
Create a public link to your image on Google Drive
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:
BASHhttps://drive.google.com/file/d/{UNIQUE_ID}/view?usp=sharing
The unique ID of our image is:
BASH1lD76TcHP3p2yLCp6gzGqnB3meoDHKpuK
From there, we can now create a public link to our image by following the below structure:
BASHhttps://drive.google.com/uc?id={UNIQUE_ID}
Just replace {UNIQUE_ID}
with the unique ID of our image.
BASHhttps://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!
- How to Install Node on Windows, macOS and Linux
- How to deploy a .NET app using Docker
- How to build a Discord bot using TypeScript
- How to deploy an Express app using Docker
- Using Puppeteer and Jest for End-to-End Testing
- How to Scrape the Web using Node.js and Puppeteer
- Getting Started with Handlebars.js
- Getting Started with Moment.js
- Learn how to build a Slack Bot using Node.js
- Using Push.js to Display Web Browser Notifications
- Building a Real-Time Note-Taking App with Vue and Firebase
- Setting Up a Local Web Server using Node.js