Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package can't installed in laravel 9 #108

Open
aronei44 opened this issue Feb 9, 2022 · 14 comments
Open

package can't installed in laravel 9 #108

aronei44 opened this issue Feb 9, 2022 · 14 comments

Comments

@aronei44
Copy link

aronei44 commented Feb 9, 2022

the problem :
- Root composer.json requires nao-pon/flysystem-google-drive 1.1.0 -> satisfiable by nao-pon/flysystem-google-drive[1.1.0].
- nao-pon/flysystem-google-drive 1.1.0 requires league/flysystem ~1.0 -> found league/flysystem[1.0.0-alpha1, ..., 1.x-dev] but these were not loaded, likely because it conflicts with another require.

@oriceon
Copy link

oriceon commented Feb 9, 2022

I have same issue

@aronei44
Copy link
Author

aronei44 commented Feb 9, 2022

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

@besartzeka
Copy link

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
- Root composer.json requires nao-pon/flysystem-google-drive ~1.1 -> satisfiable by nao-pon/flysystem-google-drive[1.1.0, ..., 1.1.x-dev].
- nao-pon/flysystem-google-drive[1.1.0, ..., 1.1.x-dev] require league/flysystem ~1.0 -> found league/flysystem[1.0.0-alpha1, ..., 1.x-dev] but the package is fixed to 3.0.3 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

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
Copy link

PaolaRuby commented Feb 9, 2022

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
Copy link

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
Copy link

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
Copy link

oriceon commented Feb 21, 2022

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

@PaolaRuby
Copy link

PaolaRuby commented Feb 21, 2022

@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
Copy link

jensCS commented May 5, 2022

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

@hckoks
Copy link

hckoks commented May 31, 2022

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
Copy link

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

@rizkytegar
Copy link

I have same issue

@parallels999
Copy link

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

@angeljqv
Copy link

angeljqv commented Jun 20, 2024

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants