GithubHelp home page GithubHelp logo

elfinder-flysystem-driver's Introduction

elFinder Flysystem Driver

This package adds a VolumeDriver for elFinder to use Flysystem as a root in your system. You need to have elFinder 2.1 installed. You can download the source or nightlies from https://github.com/Studio-42/elFinder or use the Laravel version: https://github.com/barryvdh/laravel-elfinder

Require this package in your composer.json and update composer.

composer require barryvdh/elfinder-flysystem-driver

This will require Flysystem, but you might need additional adapters to fit your purpose. See https://github.com/thephpleague/flysystem for more information.

Basic usage

You can use the driver by setting the connector config to Flysystem.

'roots' => [
    [
        'driver' => 'Flysystem', 
        'path' => 'images',
        'URL' => '/images', 
        'filesystem' => new Filesystem(new LocalAdapter('/path/to/public_html')),
        'cache' => 'session', // 'session', 'memory' or false
    ],
    [
        'driver' => 'Flysystem',
        'URL' => 'http://mydomain.com/content',
        'alias' => 'Mydomain.com',
        'filesystem' => new Filesystem(new FtpAdapter(
                [
                    'host' => 'mydomain.com',
                    'username' => 'user',
                    'password' => '****',
                    'root' => '/domains/mydomain.com/public_html/content',
                ]
            )),
    ],
    [
        'driver' => 'Flysystem',
        'adapter' => new DropboxAdapter(new Dropbox\Client($token, $appName))
    ],
];

The path and URL options are optional. The path defaults to '/', the URL is only possible when the file is visible through an URL.

Displaying thumbnails/images through Glide

If you require Glide, you can show thumbnails for your images and generate secure urls.

[
    'driver' => 'Flysystem', 
    'filesystem' => $fs,
    'glideURL' => 'http://domain.com/glideserver',
    'glideKey' => 'your-sign-key',
],

You can still use the tmbSize and tmbCrop options from the configuration options

This will require you to setup a basic server with Glide, see http://glide.thephpleague.com/ A signKey is optional, but can help secure your images against changing parameters.

Note: When securing image, you need to remove the _ parameter from your Request object: $request->query->remove('_'); Otherwise the signature will fail. The _ parameter is used to disable caching.

License

This elFinder driver is open-sourced software licensed under the MIT license

elfinder-flysystem-driver's People

Contributors

adridev avatar barryvdh avatar buzzclue avatar delatbabel avatar grossmannmartin avatar hotrush avatar lianee avatar nao-pon avatar noogen avatar taylankasap avatar wesleye avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

elfinder-flysystem-driver's Issues

Serialization of Closure is not allowed

Local file system roots seem to work just fine, but I created a s3 root with this config:

    'roots' => [
        [
            'driver' => 'Flysystem', // driver for accessing file system (REQUIRED)
            'alias' => 's3bucket',
            'URL' => url('upload/media'), // URL to files (REQUIRED)
            'adapter' => new AwsS3Adapter(new S3Client(['credentials'=>['key'=>'xxx','secret'=>'xxx'],'region'=>'','version'=>'latest']), 'mybucket'),
        ]
    ],

And in:
/var/www/html/vendor/barryvdh/elfinder-builds/php/elFinder.class.php
line 248 it throws the error
"Serialization of 'Closure' is not allowed"
I'm using Laravel 4.2 as well as "league/flysystem-aws-s3-v3"

It seems the AWSS3 adapter class has closures in it. Is it not compatible, or should the adapter not be in the place it is?

Glide thumb URL exposes base directory

Problem
Current Glide assisted thumb generation feature exposes the path information of image files.

Explanation
Let's say:

  • I store my product image files in var/data/product-images (relative to my project directory) and elFinder volume root is set to this path
  • I have a .jpg file at var/data/product-images/featured/112/main-image.jpg
  • I set the glideURL option to /product-thumbs (and I implement the correct PSR-7 Glide server there)

This driver generates a url for thumb generation that contains the base path: http://localhost:8080/product-thumbs/var/data/product-images/featured/112/main-image.jpg?ts=1582391716&w=48&h=48&fit=crop ...

The problem is, that the base path information (var/data/product-images) is exposed in the generated thumb URL. ElFinder does not expose this information in URL's (eg. for downloading without the connector).

Solution
The driver should strip the base path from the URL and base path should be set during Glide server configuration.

[BUG] Can't open folders

Hi @barryvdh I'm having troubles with the Driver. When I try to open a folder "Folder not found." is returned.

ENV:
barryvdh/elfinder-flysystem-driver v0.2.0
barryvdh/laravel-elfinder dev-master d9df120

league/flysystem 1.0.24
league/flysystem-aws-s3-v3 1.0.12
league/flysystem-cached-adapter 1.0.3

laravel/framework v5.2.39

I found the solution for my problem. If I remove the following snipped:

// return empty on failure
if (!$meta) {
    return array();
}

from vendor/barryvdh/elfinder-flysystem-driver/src/Driver.php:284 it works perfectly.

I just start using your library so I am not sure if this change will break something. Let me know about before I submit a pull request.

EDIT: Mention that I'm using an S3 bucket as Disk.

Thanks.

Files not show in elfinder using FlySystem driver

I'm having an issue trying to connect elfinder using the Flysystem driver. I would like to use both the LocalAdapter and AwsS3Adapter for the Flysystem, but either one i get the same issue.

The backend call to fetch the files returns 200 and the response json seems correct. I don't see anything specific that seems wrong within the resonse, here's a copy of the json : elfinder-s3-ouput.txt

You can see that the files array is populated and it has read the files from S3 seemingly without problem. But elfinder always ouputs the "Folder is empty Drop to add items" message. I do see the root folder in "cms_images" as the root like it should be but nothing else.

No matter the FlySystem adapter I get the same thing. Files (and Folders) returned in json but not processed by elfinder for display.

I'm posting this here on the repo for the FlySystem driver because, if i use the regular LocalFileSystem driver of elfinder, everything displays as it should no problem.

Is there some config I might be missing?

This is the config i'm using:

$options = [
    'roots' => [
        'driver'          => 'Flysystem',
        'filesystem'      => League\Flysystem\FilesystemInterface instance using AwsS3Adapter,
        'path'            => 'fichiers/cms_images', // path to files (REQUIRED)
        'tmbPath'         => 'fichiers/cms_images/.tmb',
        'URL'             => '/cms_images', // URL to files (REQUIRED)
        'tmbURL'          => '/cms_images/.tmb',
        'tmbCrop'         => false,
        'tmbBgColor'      => 'transparent',
        'tmbSize'         => 200,
        'uploadDeny'      => ['all'], // All Mimetypes not allowed to upload
        'uploadAllow'     => ['image', 'text/plain'], // Mimetype `image` and `text/plain` allowed to upload
        'uploadOrder'     => ['deny', 'allow'], // allowed Mimetype `image` and `text/plain` only
        'tmpPath'         => sys_get_temp_dir(),
        'accessControl'   => function ($attr, $path, $data, $volume) {
            // Limit visibility of . files
            $return = null;
            if (strpos(basename($path), '.') === 0) {
                $return = !($attr == 'read' || $attr == 'write');
            }
            return $return;
         }
    ]
];

Driver is reading files for mimetypes instead of listing them

Hi,

When clicking on a folder from a disk, it often finishes with 504, meaning timeout:

2017-12-13 002424

The screenshot below show that commands from elFinder driver is reading a 24Mb mp4 files instead of only doing listing:

img_13122017_194631_0

By doing that, elFinder timeout and show 504 as it is doing that for all files in folder. Imagine if you have 100 files of 5Mb.

The elFinder author found that it may be related to this:

https://github.com/barryvdh/elfinder-flysystem-driver/blob/master/src/Driver.php#L303-L323

Any idea how to mitigate this issue?

Thank you

If the mimetype is missing in metadata, glideURL won't work

On many drivers, the metadata does not contain the mimetype. This is the case for the current version of the local driver. This results in the Driver skipping the urlBuilder part.
In laravel-elfinder however, if the mimetype is null it again tries to guess the mimetype. This might explain why the issue has not come up before.
See PR #50

Class 'League\Glide\Http\UrlBuilderFactory' not found

Seems need to update elfinder-flysystem-driver/src/Driver.php to make it works with glide 1.0.0+, change

use League\Glide\Http\UrlBuilderFactory;

to

use League\Glide\Url\UrlBuilderFactory;

I can make a pr if confirmed.

S3 URL incorrect on upload when URL is specified

This was a tough one to find.

Setup:

    'disks' => [
		's3' => [
			'URL' => env('AWS_URL'),
			'alias' => 'Uploads',
		],
    ],
  1. Upload a file, example.jpg to the S3 disk
  2. Observe that the URL returned from the connector is https://bucket.s3.amazonaws.com/xample.com instead of https://bucket.s3.amazonaws.com/example.com

Working configuration:

    'disks' => [
		's3' => [
			'alias' => 'Uploads',
		],
    ],
  1. Upload a file, example.jpg to the S3 disk
  2. Observe that the URL returned from the connector is correctly https://bucket.s3.amazonaws.com/example.com

This seems to occur because when the URL option is not present, a URLCallback is set to get the URL from flysystem. If it is present, that URLCallback is not set, so it falls back to calling elFinderVolumeDriver::getContentUrl, which strips the first character from the filename before forming the base URL.

Issue connecting s3 bucket

Hi, i am having issues configuring my s3 bucket.
Not sure where exactly in the config it should go, disks? roots?

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Upload dir
    |--------------------------------------------------------------------------
    |
    | The dir where to store the images (relative from public)
    |
    */
    'dir' => ['Images'],

    /*
    |--------------------------------------------------------------------------
    | Filesystem disks (Flysytem)
    |--------------------------------------------------------------------------
    |
    | Define an array of Filesystem disks, which use Flysystem.
    | You can set extra options, example:
    |
    | 'my-disk' => [
    |        'URL' => url('to/disk'),
    |        'alias' => 'Local storage',
    |    ]
    */
    'disks' => [
        // 'uploads' => [
        //     'driver' => 'local',
        //     'root' => public_path('uploads'),
        // ],
        // 'public' => [
        //     'driver' => 'local',
        //     'root' => storage_path('app/public'),
        //     'url' => env('APP_URL').'/storage',
        //     'visibility' => 'public',
        // ],
        // 's3' => [
        //     'driver' => 's3',
        //     'key' => env('AWS_KEY'),
        //     'secret' => env('AWS_SECRET'),
        //     'region' => env('AWS_REGION'),
        //     'bucket' => env('AWS_BUCKET'),
        // ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Routes group config
    |--------------------------------------------------------------------------
    |
    | The default group settings for the elFinder routes.
    |
    */

    'route' => [
        'prefix'     => config('backpack.base.route_prefix', 'admin').'/elfinder',
        'middleware' => ['web', 'admin'], //Set to null to disable middleware filter
    ],

    /*
    |--------------------------------------------------------------------------
    | Access filter
    |--------------------------------------------------------------------------
    |
    | Filter callback to check the files
    |
    */

    'access' => 'Barryvdh\Elfinder\Elfinder::checkAccess',

    /*
    |--------------------------------------------------------------------------
    | Roots
    |--------------------------------------------------------------------------
    |
    | By default, the roots file is LocalFileSystem, with the above public dir.
    | If you want custom options, you can set your own roots below.
    |
    */

    'roots' => null,
    // 'roots' => [
    //     's3' => [
    //         'driver' => 's3',
    //         'key' => env('AWS_KEY'),
    //         'secret' => env('AWS_SECRET'),
    //         'region' => env('AWS_REGION'),
    //         'bucket' => env('AWS_BUCKET'),
    //     ],
    // ],

    /*
    |--------------------------------------------------------------------------
    | Options
    |--------------------------------------------------------------------------
    |
    | These options are merged, together with 'roots' and passed to the Connector.
    | See https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options-2.1
    |
    */

    'options' => [],

];

When placing it in roots:

Invalid backend configuration.
Readable volumes not available.

When placing it in disks:

Invalid backend response.
Error occurred on the server side.
HTTP error 500

Does my bucket need to have public access?
Any help will be much appreciated.
Thanks in advance!

s3 url not displayed

When I config my s3, I get the wrong url call out as

http://mysite.com/elfinder/connector?_token=DE1hdPclHMyBabxoEu46bWIZG1tlorw3J35641yO&cmd=file&target=fls2_RnJvbnRfcGFnZS9tZWRpdGF0aW5nVW5pY29ybi5wbmc

I can upload and see files on my s3 bucket with no problem. The only thing is I can't see the url via my s3 url.

in my config file I have my disk displayed as:

` <?php

return array(

/*
|--------------------------------------------------------------------------
| Upload dir
|--------------------------------------------------------------------------
|
| The dir where to store the images (relative from public)
|
*/
'dir' => [
    'root' => 'media',
    'private' => 'media/user',
],

/*
|--------------------------------------------------------------------------
| Filesystem disks (Flysytem)
|--------------------------------------------------------------------------
|
| Define an array of Filesystem disks, which use Flysystem.
| You can set extra options, example:
|
| 'my-disk' => [
|        'URL' => url('to/disk'),
|        'alias' => 'Local storage',
|    ]
*/
'disks' => env('FILESYSTEM_DRIVER', null),


/*
|--------------------------------------------------------------------------
| Routes group config
|--------------------------------------------------------------------------
|
| The default group settings for the elFinder routes.
|
*/

'route' => [
    'prefix' => 'elfinder',
    'middleware' => 'web', //Set to null to disable middleware filter
],

'resource_url' => 'elfinder',

/*
|--------------------------------------------------------------------------
| Access filter
|--------------------------------------------------------------------------
|
| Filter callback to check the files
|
*/

'access' => 'App\Elfinder\Elfinder::checkAccess',

/*
|--------------------------------------------------------------------------
| Roots
|--------------------------------------------------------------------------
|
| By default, the roots file is LocalFileSystem, with the above public dir.
| If you want custom options, you can set your own roots below.
|
*/

'roots' => null,

/*
|--------------------------------------------------------------------------
| Options
|--------------------------------------------------------------------------
|
| These options are merged, together with 'roots' and passed to the Connector.
| See https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options-2.1
|
*/

'options' => array(),

/*
|--------------------------------------------------------------------------
| Root Options
|--------------------------------------------------------------------------
|
| These options are merged, together with every root by default.
| See https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options-2.1#root-options
|
*/
'root_options' => array(),

);
`

I set up the environment to use local and production filesystems.
my filesystem_driver is S3 for production.

I have been trying to figure out where to setup the url, but I can't figure it out. It still throws the connector?token= string.

How do I change the base url for s3 uploads?

[0.2] Caching by default

I've implemented a SessionStore and used that by default. Alternatively, a Memory store can be used (or false to disable).

For existing caches, this relies on thephpleague/flysystem-cached-adapter#17 being merged, or passing the fscache option directly.

Also added the clearcache() method to flush the cache.

Can be tested by requiring barryvdh/elfinder-flysystem-driver:"^0.2@dev". See compare: v0.1.5...master

@nao-pon Thoughts?

Cant access url "Digital Ocean Spaces"

I cant access my image after upload to Digital Ocean Spaces.
I also try set 'visibility' => 'public' filesystem.php.
here is my configuration elfinder.php
`<?php

return array(

/*
|--------------------------------------------------------------------------
| Upload dir
|--------------------------------------------------------------------------
|
| The dir where to store the images (relative from public)
|
*/
'dir' => [],

/*
|--------------------------------------------------------------------------
| Filesystem disks (Flysytem)
|--------------------------------------------------------------------------
|
| Define an array of Filesystem disks, which use Flysystem.
| You can set extra options, example:
|
| 'my-disk' => [
|        'URL' => url('to/disk'),
|        'alias' => 'Local storage',
|    ]
*/
'disks' => [
    'public' => [
        'URL' => env('APP_URL') . '/upload',
        'path' => 'upload'
    ],
    'spaces' => [
        'URL' => 'https://'.env('DO_SPACES_BUCKET').'.sgp1.digitaloceanspaces.com',
        'acl' => 'public-read',
    ]
],

/*
|--------------------------------------------------------------------------
| Routes group config
|--------------------------------------------------------------------------
|
| The default group settings for the elFinder routes.
|
*/

'route' => [
    'prefix' => 'elfinder',
    'middleware' => array('web', 'auth'), //Set to null to disable middleware filter
],

/*
|--------------------------------------------------------------------------
| Access filter
|--------------------------------------------------------------------------
|
| Filter callback to check the files
|
*/

'access' => 'Barryvdh\Elfinder\Elfinder::checkAccess',

/*
|--------------------------------------------------------------------------
| Roots
|--------------------------------------------------------------------------
|
| By default, the roots file is LocalFileSystem, with the above public dir.
| If you want custom options, you can set your own roots below.
|
*/

'roots' => [
],

/*
|--------------------------------------------------------------------------
| Options
|--------------------------------------------------------------------------
|
| These options are merged, together with 'roots' and passed to the Connector.
| See https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options-2.1
|
*/

'options' => array(),

/*
|--------------------------------------------------------------------------
| Root Options
|--------------------------------------------------------------------------
|
| These options are merged, together with every root by default.
| See https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options-2.1#root-options
|
*/
'root_options' => array(

),

);
`

Here is filesystems.php
`<?php

return [

/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
*/

'default' => env('FILESYSTEM_DRIVER', 'local'),

/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/

'cloud' => env('FILESYSTEM_CLOUD', 's3'),

/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
*/

'disks' => [

    'local' => [
        'driver' => 'local',
        'root' => storage_path('app'),
    ],

    'public' => [
        'driver' => 'local',
        'root' => storage_path('app/public'),
        'url' => env('APP_URL').'/storage',
        'visibility' => 'public',
    ],

    'upload' => [
        'driver' => 'local',
        'root' => storage_path('app/public/upload'),
        'url' => env('APP_URL').'/storage',
        'visibility' => 'public',
    ],

    's3' => [
        'driver' => 's3',
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'region' => env('AWS_DEFAULT_REGION'),
        'bucket' => env('AWS_BUCKET'),
        'url' => env('AWS_URL'),
    ],

    'spaces' => [
        'driver' => 's3',
        'key' => env('DO_SPACES_KEY'),
        'secret' => env('DO_SPACES_SECRET'),
        'region' => env('DO_SPACES_REGION'),
        'bucket' => env('DO_SPACES_BUCKET'),
        'endpoint' => env('DO_SPACES_ENDPOINT'),
    ],

],

];
`

Elfinder connect to GCS

I am trying to make a connection between Eflinder and my GCS Buckets but I don't know how to do it and I can not found a good solutions.

Please help to solve my problem or give me the solution....!

Thanks in advance for your help...

Best Regards,

Flysystem 2.0 Support

There is currently a hard dependency on Flysystem 1.0. Are there any plans to add support for version 2?

Problem of Copy.com adapter (`scandir` return empty)

I try with

use Barracuda\Copy\API;
use League\Flysystem\Filesystem;
use League\Flysystem\Copy\CopyAdapter;
$copy_consumerKey ='*****';
$copy_consumerSecret ='*****';
$copy_accessToken ='*****';
$copy_tokenSecret ='*****';
$vol_options = array(
        array(
            'driver' => 'Flysystem',
            'filesystem' => new Filesystem(new CopyAdapter(new API($copy_consumerKey, $copy_consumerSecret, $copy_accessToken, $copy_tokenSecret)))
);

upload, mkdir, mkfile are OK but scandir return empty array so nothing is shown to cwd when reload.

How to set root for S3 access

I have got all the dependancies installed with composer but I still cannot figure out how to configure my roots to get access to my S3 bucket. I am new to php so I don't fully understand how to implement it.

Here is what I have so far:

array(
	'driver' => 'Flysystem',
	's3' => array(
		  "key" => "xxxxxxxx",
		  "secret" => "xxxxxxxx",
	          "region" => "eu-west-1"
				),
	'URL'           => 'https://s3-eu-west-1.amazonaws.com/bucketname',
	'path'          => '/',   // path relative to bucket
	'bucket' => 'bucketname',
	'acl' => 'public-read'     // depends on your case

	),

Please can someone point me in the right direction.

Can't open folders

It is the same issue as #44
Using S3 with elfinder and cannot open folder although can create folder and upload file.
When I installed the package via composer I have received old commit I think so, which has following code still in it

if (!$meta) {
return array();
}

please @barryvdh fix this issue.

step by step installing

I'm usin laravel-elfinder. when I'm trying image cropping and getting this error,

[Sun Aug 30 16:32:53 2015] PHP Fatal error: Class 'Barryvdh\elFinderFlysystemDriver\elFinder' not found in /projects/myproject/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146

I installed this package, but I can't define like this Barryvdh\elFinderFlysystemDriver\elFinder::class in app.php
[laravel 5.1]

You can tell simple way installing step by step?

"adapter" is never processed

When setting a "root" with an "adapter" rather than a filesystem, the driver init() method just fails with "A filesystem instance is required" rather than attempting to do anything with the adapter that was created for it.

Release tagging

Would you mind tagging the latest master branch? There are a few issues resolved on dev-master which 0.2.0 doesn't have.

Thanks!

composer doesnt work, depends on invalid package/version

$ composer require barryvdh/elfinder-flysystem-driver
Warning: This development build of composer is over 30 days old. It is recommended to update it by running "/usr/bin/composer self-update" to get the latest version.
Using version 0.2.* for barryvdh/elfinder-flysystem-driver
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

[RuntimeException]
Could not load package intervention/image in http://packagist.org: [UnexpectedValueException] Could not parse version constraint 4.x.x: Invalid version string "4.x.x"

[UnexpectedValueException]
Could not parse version constraint 4.x.x: Invalid version string "4.x.x"

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--sort-packages] [packages1] ... [packagesN]

Elfinder folders/files with spaces in name using flysystem

Hello,

Now that I was able to connect elfinder to a webdav online storage using this driver, I'm finding another problem.
All the files and or folders with spaces are been listed "url encoded", this means that if a file or folder has a space on it, it will be named like: file%20name.ext
On the webdav server side everything is listed as it should (file name.ext)

Is there any clue about this?

Webdav configuration

Hello Barry,

I've been trying to use your Flysystem driver for elfinder, specifically to connect to a webdav filesystem.

I'm missing something for sure...
I've installed everything through the composer and "required" all the packages... but still nothing..
The only thing I'm not sure is about the definition of the webdav root at elfinder connector.

Here are the lines:

use Sabre\DAV\Client;
use League\Flysystem\Filesystem;
use League\Flysystem\WebDAV\WebDAVAdapter;

$settings = array(
        'baseUri' => 'https://urltowebdav/',
        'userName' => 'userna',
        'password' => 'passwd',

);

$client         = new Client($settings);
$webdavAdapter  = new WebDAVAdapter($client);
$webdavfs       = new Filesystem($webdavAdapter);

$opts = array(
        'roots' => array(
                array(
                        'driver'        => 'Flysystem',
                        'filesystem'    => $webdavfs                 
                )
        )
);

Can someone help me?

Streaming uploads

Despite the GCS FlySystem Adapter supporting streaming uploads, the author of elFinder has stated that elFinder cannot do streaming uploads, it always has to upload to the server first, then upload to GCS, rather than stream straight to GCS.

Do you know how to get elFinder to stream straight to GCS?

No fallback config for cache filesystem

If the caching is enabled, the following line overwrites the $fs with a new Filesystem-object but without any configuration.

$this->fs = new Filesystem($adapter);

                if ($this->fscache) {
                    $adapter = new CachedAdapter($adapter, $this->fscache);
                    $this->fs = new Filesystem($adapter);
                }

If the configuration contains any parameters, that are important e. g. to set the visibility of files in an S3 bucket, this configuration is not available anymore.

Maybe it is a good idea to add the configuration here:

                    $this->fs = new Filesystem($adapter, $this->fs->getConfig());

Google Storage issues

I am having massive problems with GCS.

I can connect to a bucket and upload files to it. I can make directories as well, but If I try to upload to a new sub folder, it fails.

If I go to my GCS console, I can see the sub folder there.

If I refresh the page with elFinder, the sub folder cannot be seen.

I think there are issues with caching maybe?

sftp

Hello,

pls how to connect with #sftp ?

Bruno

Why instanceof instead of isFile()

if ($attributes instanceof FileAttributes) {

Why are you using instanceof instead of isFile() like you used just before that?

'type' => $attributes->isFile() ? 'file' : 'dir',

Unless I am missing something, it looks like both accomplish the same thing.

You could also just use if ($meta['type'] === 'file'), which would avoid the redundant operation alltogether.

I think the microseconds can add up in this function because it could be trying to scan a large number of files/folder.

Getting Issue when update composer

I have download elfinder from https://github.com/Studio-42/elFinder after that I am trying to update my composer using "composer require barryvdh/elfinder-flysystem-driver" for adding the Flysystem volume driver. But everytime I am getting the attached error.

screenshot from 2017-09-21 19-39-19

Please let me know where I am wrong. Below is the steps followed by me

  1. git clone https://github.com/Studio-42/elFinder.git
  2. rename folder by elFinder-211
  3. Enter in the folder and run "composer require barryvdh/elfinder-flysystem-driver"

in function _stat(), $stat['name'] is never set - remnants from older flysystem api?

in _stat() meta['filename'] is never set and $meta['extension'] is set to null (both in the check for existence in attributeCache and when constructing meta from the this->fs object).

// Set item filename.extension to `name` if exists
if (isset($meta['filename']) && isset($meta['extension'])) {
$stat['name'] = $meta['filename'];
if ($meta['extension'] !== '') {
$stat['name'] .= '.' . $meta['extension'];
}
}

Background: I was looking for a quick "temporary" fix for webdav where most of my client software set "Content-Type:" to application/octet-stream or didn't set it at all and that is the webdav server's default.
So I was intending to use the flysystem mime-type-detection package to override the anything returned as application/octet-stream

On the note of older code the import (use) block at the beginning of the file seems to have some invalid (for flysystem^3) entries:

use League\Flysystem\Cached\CachedAdapter;
use League\Flysystem\Cached\CacheInterface;

my understanding is that flysystem-cached-adapter is flysystem-1.x only

and

use League\Flysystem\Util;

went away in flysystem-2

AWS S3 delete returns ERROR_RM on success

It returns the message "Unable to remove 'Close'". It say 'Close' regardless of the filename.

It seems the issue is in Driver.php.
The _unlink method expects to return a bool although it returns $this->fs->delete($path)

The filesystems S3 adapter delete method returns the "DeleteMarker" of the result which comes from the AWS\Result data. That data response looks like this:

Aws\Result Object
(
    [data:Aws\Result:private] => Array
        (
            [DeleteMarker] => ""
            [VersionId] => ""
            [RequestCharged] => ""
            [@metadata] => Array
                (
                    [statusCode] => 204
                    [effectiveUri] => https://s3.amazonaws.com/bucketName/filename.JPG
                    [headers] => Array
                        (
                            [x-amz-id-2] => LONGHASHTHINGHERE=
                            [x-amz-request-id] => ANOTHERHASH
                            [date] => Thu, 02 Jul 2015 03:25:18 GMT
                            [server] => AmazonS3
                        )
                )
        )
)

The deleteMarker is going to be blank in most cases, unless the bucket has file versioning turned on, in which case it's going to be a string or something.

Either way, it returns an empty string in the case in which it's successful. So the file is deleted, but an error message is sent back instead. If the view is refreshed, the file is gone.

It doesn't even check the statusCode to make sure it's a 200, so I'm not sure what would happen if there were a permission error, although that's definitely on the s3 adapter side of things.

I'm not sure if the flysystem-aws-s3-v3 package is suppose to be returning a boolean, or if the elfinder-flysystem-driver should be dealing with the particular response from it.

Content type gets set to binary/octet-stream for images uploaded to S3 via elfinder-flysystem-driver

I am working on a Laravel 5 site using barryvdh/laravel-elfinder along with Glide on Amazon S3. I was unable to get glide to work at all with elfinder until I discovered that all uploaded images were being stored in S3 with content type "binary/octet-stream".

I was finally able to resolve the problem by modifying the _save function in elFinderVolumeFlysystem.php. I changed this line :

if ($this->fs->putStream($path, $fp)) {

to

if($this->fs->put($path, stream_get_contents($fp))) {

I think that storing the entire file contents instead of the stream allows flysystem to accurately guess the mime type. There is probably a better way to accomplish this, so I wanted to submit an issue for your consideration.

elfinder gridfs adapter 500 internal server error

hello..
i am trying to connect mongo gridfs adapter with elfinder.
so i have did below things but getting error "500 internal server error"

installed https://github.com/Studio-42/elFinder
installed generic flysystem driver https://github.com/barryvdh/elfinder-flysystem-driver
installed https://flysystem.thephpleague.com/adapter/gridfs/

After that all successfully installed

i have write below array in "connector.minimal.php" file.

elFinder::$netDrivers['gridfs'] = 'GridFS'; array( 'driver' => 'Flysystem', // driver for accessing file system (REQUIRED) 'adapter' => new GridFSAdapter($gridFs) )

after that created New File inside php dir "elFinderFlysystemGridFS.class.php"

use League\Flysystem\GridFS\GridFSAdapter; use League\Flysystem\Filesystem; $mongoClient = new MongoClient(); $gridFs = $mongoClient->selectDB('mydatabasename')->getGridFS(); $adapter = new GridFSAdapter($gridFs); $filesystem = new Filesystem($adapter);
after that in autoload.php file added below line

'elFinderVolumeGridFS' => ELFINDER_PHP_ROOT_PATH . '/elFinderFlysystemGridFS.connector.php',

So now getting error 500 internal server error.

so please let me know if anything is wrong...

Thanks

Error Alert when upload File using SFTP, the File is success uploaded

The _resultPath in the Driver always return false because of

if (! is_array($result)) {
    if ($this->fscache) {
        $this->fscache->flush();
    }
    $result = $this->fs->getMetaData($requestPath);
}

when using SFTPAdapter the result is only boolean and getMetaData does not return path and only return :

[
    'timestamp' => 123123,
    'size' => 123123,
    'type' => 'file',
    'visibility' =? 'public'
]

so that this

$path = ($result && isset($result['path']))? $result['path'] : false;

will always return false.

Does the getMetaData of SFTP must return path? If yes, then the issue is in SFTPAdapter, any suggestion?

Thank you.

Working config for Laravel+elfinder+S3+Glide

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 AWS_S3_* 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.