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

Files not show in elfinder using FlySystem driver #35

Open
JordinBrown opened this issue Apr 1, 2016 · 1 comment
Open

Files not show in elfinder using FlySystem driver #35

JordinBrown opened this issue Apr 1, 2016 · 1 comment

Comments

@JordinBrown
Copy link

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;
         }
    ]
];
@mattusik
Copy link

I run into same issue today, after long investigation.

I found out that in this file:
/vendor/barryvdh/elfinder-flysystem-driver/src/Driver.php

in method:
protected function _stat($path)

is this piece of code which filter out all S3 folders:

$meta = $this->fs->getMetadata($path);
// return empty on failure
if ( ! $meta) {
    return array();
}

According to S3 documentation:

In Amazon S3, buckets and objects are the primary resources, where objects are stored in buckets. Amazon S3 has a flat structure with no hierarchy like you would see in a typical file system. However, for the sake of organizational simplicity, the Amazon S3 console supports the folder concept as a means of grouping objects. Amazon S3 does this by using key name prefixes for objects. http://docs.aws.amazon.com/AmazonS3/latest/UG/FolderOperations.html

If I comment out this code, everything appears in elfinder browser so I assume that this metadata check should be skipped for S3 folders, because S3 folders have no metadata at all.

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

2 participants