barryvdh / laravel-elfinder

elFinder bundle for Laravel
746 stars 171 forks source link

Google Cloud Storage not working #283

Open gvinson opened 4 years ago

gvinson commented 4 years ago

I am integration elFinder into laravel backpack but am having trouble getting our gcs bucket synced to the file manager.

Here is my config for the elfinder "disks" - this is also in the filesystems.php config disks array

 'disks' => [
        'gcs' => [
            'driver' => 'gcs',
            'project_id' => env('GOOGLE_CLOUD_PROJECT_ID'),
            'key_file' => env('GOOGLE_CLOUD_KEY_FILE'),
            'bucket' => env('GOOGLE_CLOUD_STORAGE_BUCKET'),
            'path_prefix' => env('GOOGLE_CLOUD_STORAGE_PATH_PREFIX'),
            'storage_api_uri' => env('GOOGLE_CLOUD_STORAGE_API_URI'),
            'visibility' => env('GOOGLE_CLOUD_STORAGE_VISIBILITY'),
        ],
    ],

Here is the config for elfinder roots

'roots' => [
        [
            'driver' => 'Flysystem',
            'filesystem' => _google_cloud_storage_elfinder_root(),
        ]
    ],

and the google_cloud_storage_elfinder_root function

function _google_cloud_storage_elfinder_root()
{
    $storageClient = new \Google\Cloud\Storage\StorageClient([
        'projectId' => env('GOOGLE_CLOUD_PROJECT_ID'),
        'keyFilePath' => env('GOOGLE_CLOUD_KEY_FILE')
    ]);
    $bucket = $storageClient->bucket(env('GOOGLE_CLOUD_STORAGE_BUCKET'));
    $adapter = new \Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter($storageClient, $bucket);

    return new Illuminate\Filesystem\Filesystem($adapter);
}

Any idea what is wrong here? I keep getting an error saying "Invalid backend configuration. Readable volumes not available."

laudefe commented 3 years ago

Hi! I have the same problem, could you solve it?