Fetch files from next cloud storage and display in Laravel website

906 views Asked by At

I have a website built with Laravel. I need to fetch files from my nextcloud storage and display in the website. I have successfully installed sabre/dav to create a webdav.

$settings = array(
    'baseUri' => 'https://cloud.example.com',
    'userName' => 'admin',
    'password' => 'password'
);


$client = new \Sabre\DAV\Server($settings);

dd($client);

First I am getting 500 internal server error in dd($client) response. Second I don't know what is next. I am stuck here your help will be much appreciated

1

There are 1 answers

0
Ol D. Castor On

achieved laravel + nextcloud working with this config:

  1. installed https://github.com/protonemedia/laravel-webdav
  2. config/filesystems.php
    'disks' => [       
        ...
        'webdav' => [
            'driver'     => 'webdav',
            'baseUri'    => env('NEXTCLOUD_URL'),
            'userName'   => env('NEXTCLOUD_USER'),
            'password'   => env('NEXTCLOUD_PASSWORD'),
            'pathPrefix' => 'remote.php/dav/files/USERNAME_HERE/', // pay attention on closing slash
        ],
    ],
  1. .env
NEXTCLOUD_URL=https://nextcloud_base_url/ #https://nextcloud.example.com/
NEXTCLOUD_USER=username
NEXTCLOUD_PASSWORD=password

now you can use laravel Storage fasade like Storage::disk('webdav')->files('folder'). One thing to mention - this package can't Storage::disk('webdav')->url('path') (error This driver does not support retrieving URLs)