nao-pon / flysystem-google-drive

Flysystem adapter for Google Drive
MIT License
352 stars 128 forks source link

package can't installed in laravel 9 #108

Open aronei44 opened 2 years ago

aronei44 commented 2 years ago

the problem :

oriceon commented 2 years ago

I have same issue

aronei44 commented 2 years ago

i think its not upgraded yet. i'll waiting this great package

besartzeka commented 2 years ago

Yes I ran into the same problem. This is my exact output:

./composer.json has been updated Running composer update nao-pon/flysystem-google-drive Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages.

Problem 1

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

PaolaRuby commented 2 years ago

Duplicate of #90 Try this fork for Laravel 9.x flysystem-google-drive-ext (It uses the same config) Example: laravel-google-drive-ext-demo Give them a star if it works for you

nao-pon/flysystem-google-drive replacement examples

besartzeka commented 2 years ago

I finally fixed it using the fork mentioned by @PaolaRuby.


Make sure your .env has the necessary google api keys: (Check here if you don't know how!)

FILESYSTEM_CLOUD=google
GOOGLE_DRIVE_CLIENT_ID=xxx.apps.googleusercontent.com
GOOGLE_DRIVE_CLIENT_SECRET=xxx
GOOGLE_DRIVE_REFRESH_TOKEN=xxx
GOOGLE_DRIVE_FOLDER=my_folder_name
#GOOGLE_DRIVE_TEAM_DRIVE_ID=xxx

Create a service provider class, php artisan make:provider GoogleDriveServiceProvider, and update your boot() method as below

public function boot()
    {
       \Illuminate\Support\Facades\Storage::extend('google', function($app, $config) {
            $client = new \Google\Client();
            $client->setClientId($config['clientId']);
            $client->setClientSecret($config['clientSecret']);
            $client->refreshToken($config['refreshToken']);
            $service = new \Google\Service\Drive($client);

            $options = [];
            if(isset($config['teamDriveId'])) {
                $options['teamDriveId'] = $config['teamDriveId'];
            }

            $adapter = new \Masbug\Flysystem\GoogleDriveAdapter($service, $config['folder'] ?? '/', $options);
            $driver = new \League\Flysystem\Filesystem($adapter);
            return new \Illuminate\Filesystem\FilesystemAdapter($driver, $adapter);
        });
    }

Include App\Providers\GoogleDriveServiceProvider::class, inside the providers array of config/app.php class.

Go to config/filesystems.php and add a 'google' driver inside disks arrays, as below:

'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'),
     // 'teamDriveId' => env('GOOGLE_DRIVE_TEAM_DRIVE_ID'),
 ],

And then finally inside the routes/web.php create a test route as below

Route::get('test', function() {
     \Illuminate\Support\Facades\Storage::disk('google')->put('test.txt', 'Hello World');

    return 'New file was created!';
});

I hope you'll find this helpful. At least this is how I managed to successfully create a test.txt file in my GDRIVE.

douxlagithub commented 2 years ago

Yes, I experience the same problem. Tried what @PaolaRuby recommendation but it needs a lot of changes from my previous implementation. The new version of this repo needs to be updated hopefully!

oriceon commented 2 years ago

I receive { "error": { "errors": [ { "domain": "global", "reason": "required", "message": "Login Required", "locationType": "header", "location": "Authorization" } ], "code": 401, "message": "Login Required" } }

PaolaRuby commented 2 years ago

@oriceon your keys are wrong, or maybe your google app is on test mode, so oauth stop working after 7 days, hard to say with almost no information

@douxlagithub this package has no changes since 29 Jul 2020, maybe you can make a fork, and upgrade it: link for upgrade

jensCS commented 2 years ago

@besartzeka Did u get it to work with folderId or folderName?

hckoks commented 2 years ago

Duplicate of #90 Try this fork for Laravel 9.x flysystem-google-drive-ext (It uses the same config) Example: laravel-google-drive-ext-demo Give them a star if it works for you

No there are some issue in this package. I got issue on clean backup

PaolaRuby commented 2 years ago

@hckoks use the previus version, the last release has a problem, v2.2.0

rizkytegar commented 2 years ago

I have same issue

parallels999 commented 2 years ago

@rizkytegar the answer is there, you only have to read

angeljqv commented 5 months ago

but it needs a lot of changes from my previous implementation. The new version of this repo needs to be updated hopefully!

No changes needed, it's the same, look at nao-pon/flysystem-google-drive replacement examples

Just add 'useDisplayPaths' => false, on config array(GoogleDriveServiceProvider.php)

$options = [
    'useDisplayPaths' => false, // just add this
];

if(isset($config['teamDriveId'])) {
    $options['teamDriveId'] = $config['teamDriveId'];
}

$adapter = new GoogleDriveAdapter($service, $config['folder'] ?? '/', $options);
$driver = new Filesystem($adapter);
return new FilesystemAdapter($driver, $adapter);