All Projects → ivanvermeyen → Laravel Google Drive Demo

ivanvermeyen / Laravel Google Drive Demo

Laravel & Google Drive Storage - Demo project with Laravel 5.4

Projects that are alternatives of or similar to Laravel Google Drive Demo

Fake Gcs Server
Google Cloud Storage emulator & testing library.
Stars: ✭ 316 (+5.69%)
Mutual labels:  cloud, google, storage
Hackathon Toolkit
GCP Hackathon Toolkit
Stars: ✭ 358 (+19.73%)
Mutual labels:  cloud, google, demo
Drive
☁️ A distributed cloud based lazy drive to files integrated with Dropbox, Google Drive.
Stars: ✭ 36 (-87.96%)
Mutual labels:  cloud, google, storage
Ccat
Cloud Container Attack Tool (CCAT) is a tool for testing security of container environments.
Stars: ✭ 300 (+0.33%)
Mutual labels:  cloud, google
Cloudprober
An active monitoring software to detect failures before your customers do.
Stars: ✭ 1,269 (+324.41%)
Mutual labels:  cloud, google
Playwright Aws Lambda
Support for running Microsoft's Playwright on AWS Lambda and Google Cloud Functions
Stars: ✭ 107 (-64.21%)
Mutual labels:  cloud, google
Pi Hole Pivpn On Google Compute Engine Free Tier With Full Tunnel And Split Tunnel Openvpn Configs
Run your own privacy-first ad blocking service in the cloud for free on Google Cloud Services.
Stars: ✭ 1,141 (+281.61%)
Mutual labels:  cloud, google
Google Cloud Cpp
C++ Client Libraries for Google Cloud Services
Stars: ✭ 233 (-22.07%)
Mutual labels:  cloud, google
Backup Manager
Database backup manager for dumping to and restoring databases from S3, Dropbox, FTP, SFTP, and Rackspace Cloud
Stars: ✭ 1,589 (+431.44%)
Mutual labels:  cloud, laravel
Infracost
Cloud cost estimates for Terraform in pull requests💰📉 Love your cloud bill!
Stars: ✭ 4,505 (+1406.69%)
Mutual labels:  cloud, google
Laravel Demo Mode
A package to protect your work in progress from prying eyes
Stars: ✭ 259 (-13.38%)
Mutual labels:  laravel, demo
Google It Automation With Python
Repository to keep track of Google IT Automation with Python provided by Coursera
Stars: ✭ 86 (-71.24%)
Mutual labels:  cloud, google
Vmdash
A Cloud (vm) Dashboard that allows you to interact with multiple providers from a single panel
Stars: ✭ 71 (-76.25%)
Mutual labels:  cloud, laravel
Trino
Trino: Master your translations with command line!
Stars: ✭ 118 (-60.54%)
Mutual labels:  cloud, google
Cloudserver
Zenko CloudServer, an open-source Node.js implementation of the Amazon S3 protocol on the front-end and backend storage capabilities to multiple clouds, including Azure and Google.
Stars: ✭ 1,167 (+290.3%)
Mutual labels:  cloud, storage
Tomatoidc
TomatoIDC是一款以MIT协议开源主机销售系统,具备易于扩展的插件系统,模版系统,使用强大的Laravel框架进行驱动,能帮助你轻松的扩展主机销售业务。
Stars: ✭ 230 (-23.08%)
Mutual labels:  cloud, laravel
Arozos
General purposed Web Desktop Operating Platform / OS for Raspberry Pis, Now written in Go!
Stars: ✭ 252 (-15.72%)
Mutual labels:  cloud, storage
Laravel Robots Middleware
Enable or disable the indexing of your app
Stars: ✭ 259 (-13.38%)
Mutual labels:  google, laravel
Cloudbrute
Awesome cloud enumerator
Stars: ✭ 268 (-10.37%)
Mutual labels:  cloud, google
Hexa
Hexa: The ultimate companion for Azure. Setup and deploy in seconds
Stars: ✭ 56 (-81.27%)
Mutual labels:  cloud, storage

Laravel & Google Drive Storage

ko-fi

Demo project with Laravel 5.4

Look at the commit history to see each of the steps I have taken to set this up.

Set up this demo project locally

git clone [email protected]:ivanvermeyen/laravel-google-drive-demo.git
composer install

I took care of this:

This will also install only one additional package that is not included by Laravel out of the box:

"nao-pon/flysystem-google-drive": "~1.1"

I have included GoogleDriveAdapter and GoogleDriveServiceProvider which I have added to the providers array in config/app.php, and added a google disk in config/filesystems.php:

'disks' => [

    // ...

    'google' => [
        'driver' => 'google',
        'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'),
        'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
        'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
        'folderId' => env('GOOGLE_DRIVE_FOLDER_ID'),
        // 'teamDriveId' => env('GOOGLE_DRIVE_TEAM_DRIVE_ID'),
    ],

    // ...

],

Create your Google Drive API keys

Detailed information on how to obtain your API ID, secret and refresh token:

Update .env file

Add the keys you created to your .env file and set google as your default cloud storage. You can copy the .env.example file and fill in the blanks.

FILESYSTEM_CLOUD=google
GOOGLE_DRIVE_CLIENT_ID=xxx.apps.googleusercontent.com
GOOGLE_DRIVE_CLIENT_SECRET=xxx
GOOGLE_DRIVE_REFRESH_TOKEN=xxx
GOOGLE_DRIVE_FOLDER_ID=null
#GOOGLE_DRIVE_TEAM_DRIVE_ID=xxx

Using multiple Google Drive accounts

If you want to use multiple Google Drive accounts in a single Laravel app, you need to get the API keys for each one as described above and store them separately in your .env file:

MAIN_GOOGLE_DRIVE_CLIENT_ID=xxx.apps.googleusercontent.com
MAIN_GOOGLE_DRIVE_CLIENT_SECRET=xxx
MAIN_GOOGLE_DRIVE_REFRESH_TOKEN=xxx
MAIN_GOOGLE_DRIVE_FOLDER_ID=null

BACKUP_GOOGLE_DRIVE_CLIENT_ID=xxx.apps.googleusercontent.com
BACKUP_GOOGLE_DRIVE_CLIENT_SECRET=xxx
BACKUP_GOOGLE_DRIVE_REFRESH_TOKEN=xxx
BACKUP_GOOGLE_DRIVE_FOLDER_ID=null

Then you should add a disk in config/filesystems.php for each account using the google driver and the account specific keys:

'main_google' => [
    'driver' => 'google',
    'clientId' => env('MAIN_GOOGLE_DRIVE_CLIENT_ID'),
    'clientSecret' => env('MAIN_GOOGLE_DRIVE_CLIENT_SECRET'),
    'refreshToken' => env('MAIN_GOOGLE_DRIVE_REFRESH_TOKEN'),
    'folderId' => env('MAIN_GOOGLE_DRIVE_FOLDER_ID'),
],

'backup_google' => [
    'driver' => 'google',
    'clientId' => env('BACKUP_GOOGLE_DRIVE_CLIENT_ID'),
    'clientSecret' => env('BACKUP_GOOGLE_DRIVE_CLIENT_SECRET'),
    'refreshToken' => env('BACKUP_GOOGLE_DRIVE_REFRESH_TOKEN'),
    'folderId' => env('BACKUP_GOOGLE_DRIVE_FOLDER_ID'),
],

Now you can access the drives like so:

$mainDisk = Storage::disk('main_google');
$backupDisk = Storage::disk('backup_google');

Keep in mind that there can only be one default cloud storage drive, defined by FILESYSTEM_CLOUD in your .env (or config) file. If you set it to main_google, that will be the cloud drive:

Storage::cloud(); // refers to Storage::disk('main_google')

Available routes

Route Description
/put Puts a new test.txt file to Google Drive
/put-existing Puts an existing file to Google Drive
/list Lists all files in Google Drive (root directory, not recursive by default)
/list-folder-contents List all files in a specific folder
/get Finds and downloads the test.txt file from Google Drive
/create-dir Creates a Test Dir directory
/create-sub-dir Creates a Test Dir directory and a Sub Dir sub directory
/put-in-dir Puts a new test.txt file to the Test Dir sub directory
/newest Puts a new file to Google Drive and then fetches it
/delete Delete a file from Google Drive
/delete-dir Delete an entire directory from Google Drive
/rename-dir Rename a directory in Google Drive
/put-get-stream Use a stream to store and get larger files
/share Change permissions to share a file with the public
/export/{basename} Export a Google doc (to PDF)

This is a very basic example to get you started. To see the logic behind these routes, check routes/web.php.

Interesting Reads

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].