'Fetch files from next cloud storage and display in Laravel website
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
Solution 1:[1]
achieved laravel + nextcloud working with this config:
- installed https://github.com/protonemedia/laravel-webdav
- 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
],
],
- .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)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ol D. Castor |