barryvdh / elfinder-flysystem-driver

elFinder driver for Flysystem
184 stars 41 forks source link

Webdav configuration #41

Closed adrianopedro closed 8 years ago

adrianopedro commented 8 years ago

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?

adrianopedro commented 8 years ago

Ok...

I've found the working config and edited the previous comment with the solution. But now I've came across with other problem... I can get acces to the webdav using my computer (Finder on OSX), so thats not the problem.

Using this config I now get "HTTP error: 405" error message.

Does anyone know who is sending this error? Elfinder? Flysystem? Sabre? or my webdav server?

Thank you, AP

barryvdh commented 8 years ago

No sorry. Check your logs to see if you find any errors.

adrianopedro commented 8 years ago

Thank you for your reply. But can you at least confirm the the connection to a webdav server is working? Have you ever test it?

barryvdh commented 8 years ago

I've never used webdav.

adrianopedro commented 8 years ago

Another update... For WebDAVAdpater it is necessary to define a second argument with a prefix path. In my case '.' worked well and I can already receive the respective xml return. $webdavAdapter = new WebDAVAdapter($client,'.');

But there is still a problem, and this time I think it is from elfinder-flysystem-driver side, since it is not reading well this information.

Here goes an extract of the output:

  '/remote.php/webdav/' => 
    array (size=1)
      '{DAV:}getlastmodified' => string 'Wed, 04 May 2016 09:27:12 GMT' (length=29)
  '/remote.php/webdav/%23classified%23/' => 
    array (size=1)
      '{DAV:}getlastmodified' => string 'Wed, 20 Apr 2016 10:50:08 GMT' (length=29)
  '/remote.php/webdav/.DS_Store' => 
    array (size=3)
      '{DAV:}getcontentlength' => string '16388' (length=5)
      '{DAV:}getcontenttype' => string 'application/octet-stream' (length=24)
      '{DAV:}getlastmodified' => string 'Mon, 02 May 2016 16:37:13 GMT' (length=29)
  '/remote.php/webdav/._.DS_Store' => 
    array (size=3)
      '{DAV:}getcontentlength' => string '4096' (length=4)
      '{DAV:}getcontenttype' => string 'application/octet-stream' (length=24)
      '{DAV:}getlastmodified' => string 'Wed, 27 Apr 2016 14:46:04 GMT' (length=29)
  '/remote.php/webdav/._BIO.JPG' => 
    array (size=3)
      '{DAV:}getcontentlength' => string '4096' (length=4)
      '{DAV:}getcontenttype' => string 'image/jpeg' (length=10)
      '{DAV:}getlastmodified' => string 'Thu, 28 Apr 2016 15:44:35 GMT' (length=29)
  '/remote.php/webdav/1min_3Bs_Presentation.ppt' => 
    array (size=3)
      '{DAV:}getcontentlength' => string '311808' (length=6)
      '{DAV:}getcontenttype' => string 'application/vnd.ms-powerpoint' (length=29)
      '{DAV:}getlastmodified' => string 'Fri, 07 May 2010 11:59:09 GMT' (length=29)
  '/remote.php/webdav/1min_3bs_presentation.doc' => 
    array (size=3)
      '{DAV:}getcontentlength' => string '20992' (length=5)
      '{DAV:}getcontenttype' => string 'application/msword' (length=18)
      '{DAV:}getlastmodified' => string 'Fri, 07 May 2010 11:59:09 GMT' (length=29)
  '/remote.php/webdav/3B%27s%20Bioreactor/' => 
    array (size=1)
      '{DAV:}getlastmodified' => string 'Wed, 20 Apr 2016 10:51:01 GMT' (length=29)
  '/remote.php/webdav/3B%27s%20CE/' => 
    array (size=1)
      '{DAV:}getlastmodified' => string 'Wed, 04 May 2016 09:27:12 GMT' (length=29)

Can you check it?

adrianopedro commented 8 years ago

Back again with the solution...

The problem was the "optional" prefix that has to be defined when creating the webdavadpter. I was trying to connect elfinder to a owncloud cloud storage using flysystem and flysytem-webdav adapter.

A tipical owncloud webdav url is something like: https://owncloud_url/remote.php/webdav/and I was using it to define the baseUri, and that was the problem... when parsing the contents the "paths" were all wrong and the elfinder wans't able to get the files.

So the "trick" was to put the domain to the owncloud on the "baseUri" paramenter and the rest on the webdavadapter prefix optionanl parameter. Here is the working code to mount a owncloud drive using flysystem-webdav on elfinder:

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

$settings       = array(
                        'baseUri'   => 'https://owncloud_url',
                        'userName'  => $user,
                        'password'  => $pass,
                        'authType'  => Client::AUTH_BASIC
                        );
    $client                 = new Client($settings);
    $webdavAdapter  = new WebDAVAdapter($client,"/remote.php/webdav/");
    $webdavfs       = new Filesystem($webdavAdapter);

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

Regards, AP