barryvdh / elfinder-flysystem-driver

elFinder driver for Flysystem
183 stars 41 forks source link

Working config for Laravel+elfinder+S3+Glide #60

Open delatbabel opened 7 years ago

delatbabel commented 7 years ago

Hi, more a question or set of questions than an issue.

Like a lot of people I guess I have a combination of requirements including Laravel app + elfinder + S3 storage + Glide.

I have most of it working. My config files look like this:

config/filesystems.php

return [
    'default' => 's3',
    'cloud' => 's3',
    'disks' => [
        's3' => [
            'driver' => 's3',
            'key'    => env('AWS_S3_KEY', 'your-key'),
            'secret' => env('AWS_S3_SECRET', 'your-secret'),
            'region' => env('AWS_S3_REGION', 'your-region'),
            'bucket' => env('AWS_S3_BUCKET', 'your-bucket'),
        ],
        'file-manager' => [
            'driver' => 's3',
            'key'    => env('AWS_S3_KEY', 'your-key'),
            'secret' => env('AWS_S3_SECRET', 'your-secret'),
            'region' => env('AWS_S3_REGION', 'your-region'),
            'bucket' => env('AWS_S3_BUCKET', 'your-bucket'),
        ],
    ],
];

I have the necessary AWSS3* values stored in .env.

config/elfinder.php

For the elfinder config I have gone with the suggestion of leaving roots null and setting up the disks array instead.

return array(
    'disks' => [
        's3' => [
            'alias'     => 'S3 Storage',
            'glideURL'  => '/glide_images',
            // 'glideKey' -- REDACTED
        ],
    ],
    'roots' => null,
);

... I also have a properly working Glide installation as evidenced by being able to access images from Flysystem using the /glide_images URL.

The only thing that's not working is the elfinder/Glide integration. As per the README file in laravel-elfinder:

You should now see a root 'public' in elFinder with the files in your public folder, with thumbnails generated by Glide. URLs will also point to the Glide server, for images.

So everything is working except that I don't see any thumbnails generated by Glide, and I can't see any access to the Glide URL (as I watch the server logs) while I'm operating elfinder. elfinder access to the files in Flysystem are working and I can use the Laravel Storage facade to access/modify/delete these files without problems. Also within my Glide ImageController I have been able to inject the Laravel Filesystem contract to create the Glide ServerFactory which is working well.

Questions:

  1. Is the config with the glideUrl parameter supplied under disks supposed to work? Should I be providing the config for the Flysystem storage under roots instead?

  2. Can I somehow rely on just the flysystem configuration in config/filesystems.php to give me all of the necessary flysystem config for elfinder or do I have to duplicate that into config/elfinder.php to pass all of the necessary options for (e.g.) Glide integration?

  3. Assuming that I do have to duplicate the flysystem config into config/elfinder.php, what does a working config for S3 Flysystem access under roots look like?

Thanks,

Del

delatbabel commented 7 years ago

As a point of reference, this does not work:

    'roots' => [
        [
            'driver' => 'Flysystem',
            'glideURL'  => '/glide_images',
            // 'glideKey' REDACTED
            'alias' => 'S3 Flysystem',
            'filesystem' => new Filesystem(new AwsS3Adapter(
                new S3Client([
                    'credentials'   => [
                        'key'       => env('AWS_S3_KEY', 'your-key'),
                        'secret'    => env('AWS_S3_SECRET', 'your-secret'),
                    ],
                    'region'        => env('AWS_S3_REGION', 'your-region'),
                ]),
                env('AWS_S3_BUCKET', 'your-bucket')
            )),
        ],
    ],

... it throws errors in Illuminate\Container\Container->make('log', ...) no doubt because the log object in the application container hasn't yet been initialised.

As an alternative, trying this throws the same error:

    'roots' => [
        [
            'driver' => 'Flysystem',
            'glideURL'  => '/glide_images',
            // 'glideKey' REDACTED
            'alias' => 'S3 Flysystem',
            'filesystem' => app('filesystem')->disk(),
        ],
    ],
delatbabel commented 7 years ago

OK I found a couple of things:

Has anyone gotten image icons to work?

barryvdh commented 7 years ago

So thumbnails work? Or which icons do you mean?

delatbabel commented 7 years ago

To make it clear, these are the thumbnails that I see for all images:

https://salsa.babel.com.au/owncloud/index.php/s/7YCnZXhHrkuIiOz

When I open an info box for an image I see this:

https://salsa.babel.com.au/owncloud/index.php/s/nMCvj0A8rjp1lJt

The Link in that info box is the correct link to the file including the Glide URL. This is the information that I have that Glide integration is working (I also added a bunch of Log::debug statements in the Driver.php code to ensure that the _stat() function is doing the right thing, which it is).

pcable commented 6 years ago

I've encountered the same issue. I think it's a problem in ElFinder and I've submitted a pull request for it. https://github.com/Studio-42/elFinder/pull/2283

As @delatbabel said, the glide thumbnails urls are correct. They're just not being loaded.