Skip to content

Extract downloadable link from any Google Drive sharable link. Easy to use to embed or use direct Google Drive download link

Notifications You must be signed in to change notification settings

shahariaazam/gdrive-direct-download-link

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Drive Download Link Extractor

Code Checks Build Code Coverage Code Rating Code Intellegence

Get direct download link from any Google Drive sharable link. So you don't need to open Google Drive webpage to download the file.

Also it can help you to embed assets anywhere because the link you will extract from this library will directly download the assets without going to any middle-page.

Installation

It's very easy to use with composer. Run the following command -

composer require shahariaazam/gdrive-direct-download-link

It will add the package shahariaazam/gdrive-direct-download-link in your project.

Usage

Via Composer

<?php
use ShahariaAzam\GDriveLinkExtractor\GoogleDriveLink;

require "vendor/autoload.php";

$sharableURL = 'GOOGLE_DRIVE_SHARABLE_LINK';
$downloadLink = GoogleDriveLink::get($sharableURL);

Without Installation

It's a very tiny library. But if you don't want to install it. Here is the function that you can use.

<?php

function downloadLink($sharableLink)
{
    return preg_replace("/\/file\/d\/(.+)\/(.+)/", "/uc?export=download&id=$1", $sharableLink);
}

echo downloadLink('https://drive.google.com/file/d/FAKE_FILE_ID/view?usp=sharing');

Yes, it's that simple.

Note: I just made this as a composer package because I wanted to make it testable for future compatibility

About

Extract downloadable link from any Google Drive sharable link. Easy to use to embed or use direct Google Drive download link

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages