Python client library for KCFinder file manager
Project description
kcfinder-client
A Python client library for KCFinder, a PHP web file manager. Wraps KCFinder's HTTP action-dispatch API into a clean Python interface with both async and sync clients.
[!NOTE] Designed for and tested against HarmonySite's KCFinder fork. May work with other KCFinder instances via
SessionAuth, but this has not been tested.
Table of Contents
Install
# uv
uv add kcfinder-client
# pip
pip install kcfinder-client
Quick Start
Async (recommended)
import asyncio
import os
from kcfinder_client import AsyncKCFinderClient, HarmonySiteAuth
auth = HarmonySiteAuth(
login_url="https://example.harmonysong.com/dbaction.php",
browse_url="https://example.harmonysong.com/kcfinder/browse.php",
username="admin",
password="secret",
bros_config=(
'a:3:{s:9:"uploadDir";s:6:"files/";'
's:9:"thumbsDir";s:14:"files/.thumbs/";'
's:9:"uploadURL";s:0:"";}'
),
)
async def main():
browse_url = "https://example.harmonysong.com/kcfinder/browse.php"
async with AsyncKCFinderClient(browse_url, auth) as client:
files = await client.list_files("banners")
for f in files:
print(f.name, f.size)
asyncio.run(main())
Sync
from kcfinder_client import KCFinderClient, HarmonySiteAuth
auth = HarmonySiteAuth(
login_url="https://example.harmonysong.com/dbaction.php",
browse_url="https://example.harmonysong.com/kcfinder/browse.php",
username="admin",
password="secret",
bros_config=(
'a:3:{s:9:"uploadDir";s:6:"files/";'
's:9:"thumbsDir";s:14:"files/.thumbs/";'
's:9:"uploadURL";s:0:"";}'
),
)
browse_url = "https://example.harmonysong.com/kcfinder/browse.php"
with KCFinderClient(browse_url, auth) as client:
files = client.list_files("banners")
for f in files:
print(f.name, f.size)
Auth from Environment Variables
Load credentials from the environment rather than hardcoding them:
export KCFINDER_LOGIN_URL=https://example.harmonysong.com/dbaction.php
export KCFINDER_BROWSE_URL=https://example.harmonysong.com/kcfinder/browse.php
export KCFINDER_USERNAME=admin
export KCFINDER_PASSWORD=secret
export KCFINDER_BROS_CONFIG='a:3:{s:9:"uploadDir";s:6:"files/";s:9:"thumbsDir";s:14:"files/.thumbs/";s:9:"uploadURL";s:0:"";}'
import os
from kcfinder_client import AsyncKCFinderClient, harmonysite_auth_from_env
import asyncio
async def main():
auth = harmonysite_auth_from_env()
browse_url = os.environ["KCFINDER_BROWSE_URL"]
async with AsyncKCFinderClient(browse_url, auth) as client:
files = await client.list_files()
print(f"Found {len(files)} files")
asyncio.run(main())
Sync Files with SyncManager
One-way push sync to make a remote directory match a local one:
import os
from pathlib import Path
from kcfinder_client import KCFinderClient, SyncManagerSync, harmonysite_auth_from_env
auth = harmonysite_auth_from_env()
browse_url = os.environ["KCFINDER_BROWSE_URL"]
with KCFinderClient(browse_url, auth) as client:
sync = SyncManagerSync(client)
# Dry run first to preview changes
result = sync.push("banners", Path("./banners"), dry_run=True)
print(f"Would upload: {result.uploaded}")
print(f"Would delete: {result.deleted}")
print(f"Would skip: {result.skipped}")
# Apply the sync
result = sync.push("banners", Path("./banners"))
Documentation
- Auth setup — HarmonySiteAuth, SessionAuth, env vars
- File operations — list, upload, download, delete, rename, thumbnails
- Directory operations — tree, expand, create, rename, delete
- Bulk operations — copy, move, bulk delete, download selected
- Sync manager — push sync, dry run, SyncResult
- Exceptions — error handling, exception hierarchy
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kcfinder_client-0.2.0.tar.gz.
File metadata
- Download URL: kcfinder_client-0.2.0.tar.gz
- Upload date:
- Size: 54.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb142434270b10b866a72aa92114fb965d9f7baa66700a6a334babfa613c115e
|
|
| MD5 |
e7920e00efcdece5344121e65854c120
|
|
| BLAKE2b-256 |
c0d757026040de0132777dd2d9700d79c8d786c1348040ae1dda412cc3a8131f
|
Provenance
The following attestation bundles were made for kcfinder_client-0.2.0.tar.gz:
Publisher:
publish.yml on cyberops7/kcfinder-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kcfinder_client-0.2.0.tar.gz -
Subject digest:
cb142434270b10b866a72aa92114fb965d9f7baa66700a6a334babfa613c115e - Sigstore transparency entry: 1282263514
- Sigstore integration time:
-
Permalink:
cyberops7/kcfinder-client@6393cc5be2b7f41d9e4901f94bd3449ceb47c875 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/cyberops7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6393cc5be2b7f41d9e4901f94bd3449ceb47c875 -
Trigger Event:
release
-
Statement type:
File details
Details for the file kcfinder_client-0.2.0-py3-none-any.whl.
File metadata
- Download URL: kcfinder_client-0.2.0-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9aa5f3226aef675f60a0c42f73216a542800fd4325b6dc9bce497597f92946c9
|
|
| MD5 |
353b43fc933c3549e9a39f414358f8d5
|
|
| BLAKE2b-256 |
e4eb4c2ea9d319b5243989fc3196acc911b962bb8dbd2cbf911d34cfb8a9d29f
|
Provenance
The following attestation bundles were made for kcfinder_client-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on cyberops7/kcfinder-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kcfinder_client-0.2.0-py3-none-any.whl -
Subject digest:
9aa5f3226aef675f60a0c42f73216a542800fd4325b6dc9bce497597f92946c9 - Sigstore transparency entry: 1282263556
- Sigstore integration time:
-
Permalink:
cyberops7/kcfinder-client@6393cc5be2b7f41d9e4901f94bd3449ceb47c875 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/cyberops7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6393cc5be2b7f41d9e4901f94bd3449ceb47c875 -
Trigger Event:
release
-
Statement type: