godav

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2025 License: MIT Imports: 9 Imported by: 0

README

CI CodeQL Coverage Status Open Issues Go Report Card GitHub release (latest by date)

godav

🚀 A Go library for WebDAV with full support for Nextcloud chunked uploads and advanced file operations.

Features

  • High-level client for Nextcloud WebDAV
  • Chunked uploads (bypass proxy body-size limits)
  • Recursive directory uploads
  • Progress reporting and verbose logging
  • Skips files that already exist with the same size

Installation

go get github.com/tlmanz/godav

Usage

package main

import (
	"github.com/tlmanz/godav"
)

func main() {
	client := godav.NewClient("https://nextcloud.example.com/remote.php/dav/", "username", "password")
	config := godav.DefaultConfig()
	config.Verbose = true

	// Upload a single file
	err := client.UploadFile("/path/to/local/file.txt", "remote/path/file.txt", config)
	if err != nil {
		panic(err)
	}

	// Upload a directory recursively
	err = client.UploadDir("/path/to/local/dir", "remote/path/dir", config)
	if err != nil {
		panic(err)
	}
}

Configuration

You can customize upload behavior using the Config struct:

type Config struct {
	ChunkSize    int64                   // Chunk size in bytes (default 10MB)
	SkipExisting bool                    // Skip files that exist with same size
	Verbose      bool                    // Enable verbose logging
	ProgressFunc func(info ProgressInfo) // Progress callback with detailed info
}

Example: Show upload progress

config.ProgressFunc = func(info godav.ProgressInfo) {
	fmt.Printf("Uploading %s: %.1f%%\n", info.Filename, info.Percentage)
}

License

This project is licensed under the MIT License.

Documentation

Overview

Package nextcloud provides a high-level client for Nextcloud WebDAV operations, including chunked uploads that bypass proxy body-size limits.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*gowebdav.Client
	// contains filtered or unexported fields
}

Client wraps a gowebdav.Client with Nextcloud-specific operations.

func NewClient

func NewClient(baseURL, username, password string) *Client

NewClient creates a new Nextcloud WebDAV client.

func (*Client) SetVerbose

func (c *Client) SetVerbose(verbose bool)

SetVerbose enables or disables verbose logging.

func (*Client) UploadDir

func (c *Client) UploadDir(localDir, dstDir string, config *Config) error

UploadDir uploads a directory recursively using chunked uploads.

func (*Client) UploadFile

func (c *Client) UploadFile(localPath, dstPath string, config *Config) error

UploadFile uploads a single file using Nextcloud's chunked upload protocol. The dstPath is relative to the user's files directory.

type Config

type Config struct {
	ChunkSize    int64                   // Chunk size in bytes (default 10MB)
	SkipExisting bool                    // Skip files that exist with same size
	Verbose      bool                    // Enable verbose logging
	ProgressFunc func(info ProgressInfo) // Progress callback with detailed info
}

Config holds options for upload operations.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns sensible defaults for upload operations.

type ProgressInfo

type ProgressInfo struct {
	Filename    string  // Name of the file being uploaded
	Current     int64   // Bytes uploaded so far
	Total       int64   // Total file size in bytes
	Percentage  float64 // Upload progress as percentage (0.0 to 100.0)
	ChunkIndex  int     // Current chunk number (0-based)
	TotalChunks int     // Total number of chunks
}

ProgressInfo contains detailed progress information for uploads.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL