How to Get Direct Download URLs from Google Drive
Need to programmatically access files stored in Google Drive? Or perhaps you’re integrating with a third-party API that requires direct media URLs, such as a URL to an image or video? While Google Drive’s standard sharing creates links that open in the Drive web app, there is a way to get direct Google Drive download URLs that bypass the web interface entirely.
The Problem with Regular Google Drive Sharing
When you use Google Drive’s standard sharing feature, you get a link like this:
https://drive.google.com/file/d/1ABC123...XYZ789/view?usp=sharing
This link opens the Google Drive web interface (web app), which means:
- Your application has to handle the Drive web app interface. It is difficult, to say the least, to programmatically download from the web app. Meaning…
- Third-party APIs can’t directly access the file.
- Additional clicks are required to actually download the content.
- Automation becomes more complicated or impossible.
Google Drive web app interface in a web browser:

The Solution: Converting to Direct Download URLs
Luckily, Google provides a way to get a direct download link that bypass the web app.
Here’s how to get a direct download URL:
Step 1: Make Your File Public
- Open your file in Google Drive.
- Click “Share” in the top-right corner.
- Change access to “Anyone with the link”.
- Copy the sharing link.
The link will be in the format:
https://drive.google.com/file/d/FILE_ID/view?usp=sharing
Where the FILE_ID
is the id of the Google Drive file. You’ll use this id in the next step.
Step 2: Transform the URL to a Download URL
Take your sharing link and convert it to this format:
https://drive.google.com/uc?export=view&id=FILE_ID
Just copy the FILE_ID (the long string between /d/ and /view) from your sharing link and insert it into the new format.
It will look like this:
https://drive.google.com/uc?export=view&id=1ABC123XYZ789
Here is an example of the Google Drive Direct download URL in the web browser:

Common Use Cases for Direct URLs
These converted direct download URLs are particularly useful for:
- Programmatic file downloads that you call from with the front-end or back-end.
- Third-party API integrations.
- Including in HTML with an
<img>
element. - Automated content management systems that need direct access.
Quick Implementation for Developers
Here’s a simple JavaScript function to convert sharing links to direct Google Drive URLs:
// Convert the Google Drive share to a direct download URL
const getDirectDownloadUrl = (driveLink) => {
const fileId = driveLink.match(/\/d\/(.*?)\/view/)?.[1];
if (!fileId) {
throw new Error('Invalid Google Drive sharing URL');
}
return `https://drive.google.com/uc?export=view&id=${fileId}`;
};
// Example usage
const sharingUrl = 'https://drive.google.com/file/d/1ABC123...XYZ789/view?usp=sharing';
const directUrl = getDirectDownloadUrl(sharingUrl);
Important Considerations
While this method works, keep in mind:
- Large files might load slowly since Google Drive isn’t optimized for content delivery. Google Drive is not meant to act as an AWS S3 bucket.
- For production applications, consider using proper file hosting services such as S3.
- There’s no guarantee Google won’t change how this works in the future. Yes, this is a bit of a hack.
- Rate limiting may apply for frequent downloads.
Better Alternatives for Production Use
If you need regular programmatic file access, consider these alternatives:
- Amazon S3 for cloud storage. Our favorite.
- Firebase Storage for web applications. This uses Google Cloud Storage behind the scenes.
- Google Cloud Storage for enterprise needs.
- Dedicated CDNs for content delivery.
- Specialized file hosting services.
Conclusion
This direct URL method is useful for development, testing, and API situations where you need to bypass the Drive web interface. However, for production environments or high-traffic scenarios, dedicated file hosting services will provide better reliability and performance.
Note: The Ayrshare social API automatically converts Google Drive share URLs to direct download URL, so you don’t need to worry about the conversion. Also, Ayrshare offers direct media uploading with the /media endpoint. We recommend Ayrshare clients use this if you can’t host somewhere else.