whs-junkyard / elFinder-driver

*unmaintained* Drivers for elFinder
11 stars 5 forks source link

Use with Connector #2

Closed mssteuer closed 10 years ago

mssteuer commented 10 years ago

I'm trying to use your S3 class with the elFinder connector but have no luck in getting it to work. Also, do I need to set any CORS policy on the bucket?

here's what I have for the connector:

include_once APPLICATION_PATH . '/../resources/skin/plugins/elfinder/php/elFinderConnector.class.php';
            include_once APPLICATION_PATH . '/../resources/skin/plugins/elfinder/php/elFinder.class.php';
            include_once APPLICATION_PATH . '/../resources/skin/plugins/elfinder/php/elFinderVolumeDriver.class.php';
            include_once APPLICATION_PATH . '/../resources/skin/plugins/elfinder/php/elFinderVolumeS3.class.php';

            $opts = array(
                // 'debug' => true,
                'roots' => array(
                    array(
                        'driver'        => 'S3',  
                        "s3" => array(
                            "key" => AWS_KEY,
                            "secret" => AWS_SECRET,
                            "region" => "us-east-1"
                        ),
                        "bucket" => "xxxxx",
                        "acl" => "public-read-write"
                    )
                )
            );

            $connector = new elFinderConnector(new elFinder($opts));
            $connector->run();

Your help/tips are much appreciated!

Thanks,

michael.

PS. also, what should the "path" and "url" options be in the 'roots' elements? Without those I get a "Invalid backend configuration. Readable volumes not available" error. If I specify a sub-folder of my root in the S3 bucket, it throws a NoSuchKeyException

whs commented 10 years ago

Is there any errors? Try using the web inspector and inspect the HTTP requests.

I don't have any special permission setup on my test bucket.

mssteuer commented 10 years ago

See above for comments. In your example you're not using the path and url options, but without those, elFinder won't work apparently. What should they be relative to S3? I figures just "/" and "http://url_to_s3_bucket" respectively, but that doesn't work either.

whs commented 10 years ago

Ah, seems that I forgot the path and URL configuration as it was in a seperate file from my project.

The path is relative to the bucket (can be non-existing but the bucket must exists), and for the URL I used my own script to read data from S3 with custom permission. I tried 'URL' => 'https://s3-ap-southeast-1.amazonaws.com/bucketname/' and it works.

mssteuer commented 10 years ago

OK i can now access a subfolder of the bucket (path => 'subfolder', URL => 'https://s3.amazonaaws.com/bucketname/')...

I cannot however reach the top level (root) of the bucket... if I set path to '/' or '' it fails... Thoughts?

mssteuer commented 10 years ago

Thanks so much for the real time / live support by the way! :+1:

whs commented 10 years ago

elFinder is designed that the path is always set, but S3 root directory is not '/' but a empty string. I tried removing the code on elFinderVolumeDriver.php@544-546 but it is still not working.

So.. I can't fix this one, sorry.