PHP code example of yaza / laravel-google-drive-storage
1. Go to this page and download the library: Download yaza/laravel-google-drive-storage library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yaza / laravel-google-drive-storage example snippets
use Yaza\LaravelGoogleDriveStorage\Gdrive;
Gdrive::put('location/filename.png', $request->file('file'));
// or
Gdrive::put('filename.png', public_path('path/filename.png'));
use Yaza\LaravelGoogleDriveStorage\Gdrive;
$data = Gdrive::get('path/filename.png');
return response($data->file, 200)
->header('Content-Type', $data->ext);
use Yaza\LaravelGoogleDriveStorage\Gdrive;
$readStream = Gdrive::readStream('path/filename.png');
return response()->stream(function () use ($readStream) {
fpassthru($readStream->file);
}, 200, [
'Content-Type' => $readStream->ext,
//'Content-disposition' => 'attachment; filename="'.$filename.'"', // force download?
]);