Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

This module allows Drupal to interact with NextCloud servers using the WebDAV protocol. You can manage folders, upload local files or Drupal file entities, and even upload text content directly to your NextCloud instance. It also provides features like batch operations, detailed logging, and an administration interface for easy configuration and testing.

NextCloud WebDAV Client

Seamless NextCloud integration for Drupal via WebDAV protocol

The NextCloud WebDAV Client module provides integration between Drupal and NextCloud servers using the WebDAV protocol. This module enables you to create folders, upload files, and manage content directly from your Drupal application to your NextCloud instance.

Features

  • Folder Management - Create single folders or nested folder structures
  • File Upload - Upload files from local filesystem or Drupal file entities
  • Content Upload - Upload text content directly as files
  • Directory Listing - List files and folders with metadata
  • Batch Operations - Upload multiple files at once
  • Configuration Management - Easy admin interface with connection testing
  • Comprehensive Logging - Detailed logging and debugging tools

Requirements

  • Drupal 10 or 11
  • NextCloud server with WebDAV enabled
  • Valid NextCloud user credentials or app passwords
  • HTTPS connection (recommended for production)

Installation

Via Composer (Recommended)

composer require drupal/nextcloud_webdav_client

Enable and Configure

  1. Enable the module: drush en nextcloud_webdav_client
  2. Configure connection settings at /admin/config/services/nextcloud-webdav
  3. Test your connection using the built-in test interface

Configuration

Navigate to Administration > Configuration > Web Services > NextCloud WebDAV to configure:

Connection Settings

  • Server URL: Your NextCloud server URL (e.g., https://cloud.example.com)
  • Username: Your NextCloud username
  • Password: NextCloud password or app password (recommended)
  • Base Path: WebDAV base path (usually /remote.php/dav/files/)

Advanced Settings

  • Timeout: Request timeout in seconds (default: 30)
  • Verify SSL: SSL certificate verification (recommended: enabled)

Usage Examples

Using the Manager Service

// Get the manager service
$webdav_manager = \Drupal::service('nextcloud_webdav_client.manager');

// Create a folder
$webdav_manager->createFolder('my-folder/subfolder');

// Upload a Drupal file entity
$file = File::load($file_id);
$webdav_manager->uploadDrupalFile($file, 'uploads/myfile.pdf');

// Upload content as a file
$content = "Hello, NextCloud!";
$webdav_manager->uploadContent($content, 'messages/hello.txt');

// List directory contents
$items = $webdav_manager->listDirectory('my-folder');

Custom Module Integration

/**
 * Implements hook_file_insert().
 */
function mymodule_file_insert(FileInterface $file) {
  $webdav_manager = \Drupal::service('nextcloud_webdav_client.manager');
  
  if ($webdav_manager->isConfigured()) {
    // Auto-upload files to NextCloud
    $remote_path = 'drupal-uploads/' . $file->getFilename();
    $webdav_manager->uploadDrupalFile($file, $remote_path);
  }
}

API Reference

NextCloudWebDavManager

The main service for high-level operations:

  • isConfigured() - Check if module is configured
  • testConnection() - Test connection to NextCloud
  • createFolder(string $path) - Create folder(s)
  • uploadDrupalFile(FileInterface $file, string $remote_path, bool $create_folders) - Upload Drupal file
  • uploadFile(string $local_path, string $remote_path, bool $create_folders) - Upload local file
  • uploadContent(string $content, string $remote_path, bool $create_folders) - Upload content as file
  • listDirectory(string $path) - List directory contents
  • uploadMultipleFiles(array $files, bool $create_folders) - Batch upload files

NextCloudWebDavClient

The low-level WebDAV client service:

  • testConnection() - Test WebDAV connection
  • createFolder(string $path) - Create single folder
  • uploadFile(string $local_path, string $remote_path) - Upload file
  • uploadContent(string $content, string $remote_path) - Upload content
  • listDirectory(string $path) - List directory

Security Considerations

Important: Follow these security best practices:

  • Use NextCloud app passwords instead of your main password
  • Create dedicated service accounts with minimal permissions
  • Enable HTTPS everywhere
  • Keep the "Verify SSL" option enabled in production
  • Regular password rotation

Creating NextCloud App Passwords

  1. Log into your NextCloud web interface
  2. Go to Settings > Personal > Security
  3. Scroll to "App passwords" section
  4. Enter a name (e.g., "Drupal WebDAV") and click "Create new app password"
  5. Copy the generated password and use it in the module configuration

Troubleshooting

Connection Issues

  • Verify server URL is correct and accessible
  • Check username and password/app password
  • Ensure NextCloud WebDAV is enabled
  • Check SSL certificate issues

Upload Issues

  • Verify file permissions on local files
  • Check NextCloud storage quota
  • Ensure target directory exists or enable folder creation

Debugging

Enable logging and check Reports > Recent log messages for detailed error information. Use the test interface at /admin/config/services/nextcloud-webdav/test for debugging.

Permissions

The module defines two permissions:

  • Administer NextCloud WebDAV - Configure connection settings
  • Use NextCloud WebDAV - Use WebDAV functionality and test interface

Testing Interface

Visit /admin/config/services/nextcloud-webdav/test to access the testing interface where you can:

  • Create folders
  • Upload files via web interface
  • Upload text content
  • List directory contents
  • Debug WebDAV responses

Contributing

This module follows Drupal coding standards and best practices. When contributing:

  • Follow Drupal coding standards
  • Add appropriate documentation
  • Include error handling and logging
  • Write tests for new functionality

License: GPL v2 or later

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
May 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Core Release date
1.0.x-dev Dev 10–11 May 25, 2025