Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mahirshah07/pynextcloud
A Python library for interacting with Nextcloud via WebDAV
https://github.com/mahirshah07/pynextcloud
library nextcloud pypi
Last synced: 7 days ago
JSON representation
A Python library for interacting with Nextcloud via WebDAV
- Host: GitHub
- URL: https://github.com/mahirshah07/pynextcloud
- Owner: MahirShah07
- License: mit
- Created: 2025-02-01T08:18:45.000Z (8 days ago)
- Default Branch: main
- Last Pushed: 2025-02-01T09:23:07.000Z (8 days ago)
- Last Synced: 2025-02-01T10:23:53.283Z (8 days ago)
- Topics: library, nextcloud, pypi
- Language: HTML
- Homepage: https://pypi.org/project/pyNextcloud/
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```bash
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:
```bash
export NEXTCLOUD_URL="your_nextcloud_url"
export USERNAME="your_username"
export PASSWORD="your_password"
```- On Windows:
```cmd
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
```python
from pyNextcloud.nextcloud import UploadFileUploadFile('local_path.txt', 'remote_path.txt')
```### Download a File
```python
from pyNextcloud.nextcloud import DownloadFileDownloadFile('local_path.txt', 'remote_path.txt')
```### Check if a Directory Exists
```python
from pyNextcloud.nextcloud import DirectoryExists_Checkresult = DirectoryExists_Check('remote_directory')
print(result)
```### Create a Directory
```python
from pyNextcloud.nextcloud import CreateDirectoryresult = CreateDirectory('new_directory')
print(result)
```### Rename or Move a File/Directory
```python
from pyNextcloud.nextcloud import RenamePathresult = RenamePath('current_path.txt', 'new_path.txt')
print(result)
```### Delete a File/Directory
```python
from pyNextcloud.nextcloud import DeletePathresult = DeletePath('target_path.txt')
print(result)
```### Upload a Folder
```python
from pyNextcloud.nextcloud import UploadFolderresult = UploadFolder('local_folder', 'remote_folder')
print(result)
```## Running Tests
To run the tests, use the following command:
```bash
python -m unittest discover -s tests
```## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Contributing
Contributions are welcome! Please open an issue or submit a pull request for any changes.
## Acknowledgements
- [Nextcloud](https://nextcloud.com/) for providing the WebDAV interface.
- [Requests](https://docs.python-requests.org/en/master/) for making HTTP requests simple.
- [python-dotenv](https://github.com/theskumar/python-dotenv) for managing environment variables.