Skip to main content

A Python library for interacting with Nextcloud via WebDAV

Project description

pyNextcloud

pyNextcloud is a Python library for interacting with Nextcloud via WebDAV. It provides functions to upload, download, rename, delete files and directories, and check for directory existence.

Features

  • Upload files and folders to Nextcloud
  • Download files from Nextcloud
  • Rename or move files and directories
  • Delete files and directories
  • Check if a directory exists
  • Configuration using environment variables or a .env file

Installation

To install pyNextcloud, use pip:

pip install pyNextcloud

Configuration

To store the NEXTCLOUD_URL, USERNAME, and PASSWORD securely in your library, you can make use of environment variables or a configuration file to keep them safe and accessible in your app. Here's how you can do both:

1. Using Environment Variables (Recommended for security)

You can store these sensitive values in environment variables, so they aren't hardcoded in your source code.

Steps:

  • Set up environment variables on your system or in your deployment environment:
    • On Unix/Linux/Mac:

      export NEXTCLOUD_URL="your_nextcloud_url"
      export USERNAME="your_username"
      export PASSWORD="your_password"
      
    • On Windows:

      set NEXTCLOUD_URL="your_nextcloud_url"
      set USERNAME="your_username"
      set PASSWORD="your_password"
      

2. Using a Configuration File (Not as secure as environment variables)

If you'd rather use a configuration file, you can store them in a .env or JSON file.

.env File Example:

  • Create a .env file:
    NEXTCLOUD_URL=your_nextcloud_url
    USERNAME=your_username
    PASSWORD=your_password
    

Usage

Upload a File

from pyNextcloud.nextcloud import UploadFile

UploadFile('local_path.txt', 'remote_path.txt')

Download a File

from pyNextcloud.nextcloud import DownloadFile

DownloadFile('local_path.txt', 'remote_path.txt')

Check if a Directory Exists

from pyNextcloud.nextcloud import DirectoryExists_Check

result = DirectoryExists_Check('remote_directory')
print(result)

Create a Directory

from pyNextcloud.nextcloud import CreateDirectory

result = CreateDirectory('new_directory')
print(result)

Rename or Move a File/Directory

from pyNextcloud.nextcloud import RenamePath

result = RenamePath('current_path.txt', 'new_path.txt')
print(result)

Delete a File/Directory

from pyNextcloud.nextcloud import DeletePath

result = DeletePath('target_path.txt')
print(result)

Upload a Folder

from pyNextcloud.nextcloud import UploadFolder

result = UploadFolder('local_folder', 'remote_folder')
print(result)

Running Tests

To run the tests, use the following command:

python -m unittest discover -s tests

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any changes.

Acknowledgements

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pynextcloud-1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyNextcloud-1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file pynextcloud-1.0.tar.gz.

File metadata

  • Download URL: pynextcloud-1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pynextcloud-1.0.tar.gz
Algorithm Hash digest
SHA256 f43718da3e744d349a52fe725cf041bf3687677214e051b12b7f67d72bc261eb
MD5 e74f7f221abbb20cae18f2aac17b960d
BLAKE2b-256 383e077541a5b72f1920696b2466995a58f2c80d7c5efbcb2d4e31355fa53cd7

See more details on using hashes here.

File details

Details for the file pyNextcloud-1.0-py3-none-any.whl.

File metadata

  • Download URL: pyNextcloud-1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pyNextcloud-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 12795e36a9d79d49cde2ea2b8ae47e245dd87b63267765abf4cee82b9d9fc63a
MD5 b91c0c86f59ac83c3b35306e8c9e88e7
BLAKE2b-256 0c38c5892f56580ff0fdc8671accc21b63c31cb15e1dda74be74aed34f5d64bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page