Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
# Conflicts:
#	config/google-drive-storage.php
#	src/LaravelGoogleDriveStorageServiceProvider.php
  • Loading branch information
yaza-putu committed Dec 2, 2022
2 parents 4e525c4 + 7f2e624 commit 238e606
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 74 deletions.
74 changes: 28 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
# This is my package laravel-google-drive-storage

[![Latest Version on Packagist](https://img.shields.io/packagist/v/yaza/laravel-google-drive-storage.svg?style=flat-square)](https://packagist.org/packages/yaza/laravel-google-drive-storage)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/yaza/laravel-google-drive-storage/run-tests?label=tests)](https://github.com/yaza/laravel-google-drive-storage/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/yaza/laravel-google-drive-storage/Fix%20PHP%20code%20style%20issues?label=code%20style)](https://github.com/yaza/laravel-google-drive-storage/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/yaza/laravel-google-drive-storage.svg?style=flat-square)](https://packagist.org/packages/yaza/laravel-google-drive-storage)

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

## Support us

[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/laravel-google-drive-storage.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/laravel-google-drive-storage)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
# laravel-google-drive-storage
![gdrive](https://is4-ssl.mzstatic.com/image/thumb/Purple122/v4/d9/cb/a8/d9cba8b1-85a0-723a-3f03-bdc6b76476d5/logo_drive_2020q4_color-0-1x_U007emarketing-0-0-0-6-0-0-0-85-220.png/1200x630wa.png)
This package allow to store and get data from google drive like S3 AWS in laravel

## Installation

Expand All @@ -23,44 +10,37 @@ You can install the package via composer:
composer require yaza/laravel-google-drive-storage
```

You can publish and run the migrations with:

```bash
php artisan vendor:publish --tag="laravel-google-drive-storage-migrations"
php artisan migrate
copy to .env
```env
GOOGLE_DRIVE_CLIENT_ID=xxx.apps.googleusercontent.com
GOOGLE_DRIVE_CLIENT_SECRET=xxx
GOOGLE_DRIVE_REFRESH_TOKEN=xxx
GOOGLE_DRIVE_FOLDER=
```

You can publish the config file with:

```bash
php artisan vendor:publish --tag="laravel-google-drive-storage-config"
example
```env
GOOGLE_DRIVE_CLIENT_ID=xxx.apps.googleusercontent.com
GOOGLE_DRIVE_CLIENT_SECRET=xxx
GOOGLE_DRIVE_REFRESH_TOKEN=xxx
GOOGLE_DRIVE_FOLDER=backups
```

This is the contents of the published config file:

```php
return [
];
```

Optionally, you can publish the views using

```bash
php artisan vendor:publish --tag="laravel-google-drive-storage-views"
```
## Support Laravel
- php 8.1
- now only support laravel 9

## Setup Google Keys
- [Getting your Client ID and Secret](https://github.com/ivanvermeyen/laravel-google-drive-demo/blob/master/README/1-getting-your-dlient-id-and-secret.md)
- [Getting your Refresh Token](https://github.com/ivanvermeyen/laravel-google-drive-demo/blob/master/README/2-getting-your-refresh-token.md)
## Usage

you can use storage driver function by laravel <br>
example :
```php
$laravelGoogleDriveStorage = new Yaza\LaravelGoogleDriveStorage();
echo $laravelGoogleDriveStorage->echoPhrase('Hello, Yaza!');
Storage::disk('google')->put($filename, File::get($filepath));
```

## Testing

```bash
composer test
```
## Limitations
Using display paths as identifiers for folders and files requires them to be unique. Unfortunately Google Drive allows users to create files and folders with same (displayed) names. In such cases when unique path cannot be determined this adapter chooses the oldest (first) instance. In case the newer duplicate is a folder and user puts a unique file or folder inside the adapter will be able to reach it properly (because full path is unique).

## Changelog

Expand All @@ -79,6 +59,8 @@ Please review [our security policy](../../security/policy) on how to report secu
- [yaza](https://github.com/yaza-putu)
- [All Contributors](../../contributors)

Thanks to [Masbug](https://github.com/masbug/flysystem-google-drive-ext)

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
14 changes: 0 additions & 14 deletions config/filesystems.php

This file was deleted.

10 changes: 1 addition & 9 deletions config/google-drive-storage.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
<?php

return [
'google' => [
'driver' => 'google',
'client_id' => env('GOOGLE_DRIVE_CLIENT_ID'),
'client_secret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
'refresh_token' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
'folder_id' => env('GOOGLE_DRIVE_FOLDER_ID'),
],
];
return [];
14 changes: 9 additions & 5 deletions src/Commands/LaravelGoogleDriveStorageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@

class LaravelGoogleDriveStorageCommand extends Command
{
public $signature = 'laravel-google-drive-storage';
public $signature = '
gdrive:config {name : The name of command}
';

public $description = 'My command';
public $description = 'Publish Config Gdrive';

public function handle(): int
{
$this->comment('All done');

return self::SUCCESS;
try {
return self::SUCCESS;
} catch (\Exception $exception) {
return self::FAILURE;
}
}
}
12 changes: 12 additions & 0 deletions src/LaravelGoogleDriveStorageServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ public function configurePackage(Package $package): void
public function bootingPackage()
{
try {
<<<<<<< HEAD
=======
app()->config['filesystems.disks.google'] = [
'driver' => 'google',
'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'),
'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
'folder' => env('GOOGLE_DRIVE_FOLDER'), // without folder is root of drive or team drive
//'teamDriveId' => env('GOOGLE_DRIVE_TEAM_DRIVE_ID'),
];

>>>>>>> development
Storage::extend('google', function ($app, $config) {
$options = [];

Expand Down

0 comments on commit 238e606

Please sign in to comment.