Python Implement for FastDFS Client
Project description
fastdfs-client-python
FastDFS Python client
Manual pass upload test with fastdfs v6.12.1
English | 中文
Motivation
Base on:
Fixes:
- TypeError:
Traceback (most recent call last):
File "~/trying/something/upload.py", line 4, in <module>
client = Fdfs_client(tracker_conf_path)
File "~/trying/something/venv/lib/python3.10/site-packages/fdfs_client/client.py", line 52, in __init__
self.tracker_pool = poolclass(**self.trackers)
TypeError: fdfs_client.connection.ConnectionPool() argument after ** must be a mapping, not str
- ResponseError
fdfs_client.exceptions.ResponseError: [-] Error: Tracker response length is invaild, expect: 40, actual: 70
Requires
- Python3.10+ (No other dependence)
For Python3.8/Python3.9, use https://github.com/waketzheng/fastdfs-client-python/tree/1.0.1
Install
pip install fastdfs-client
Usage
from fastdfs_client import FastdfsClient
client = FastdfsClient('/etc/fdfs/client.conf')
ret = client.upload_by_filename('test.txt')
print(ret)
- Response sample
{
"Group name": "group1",
"Status": "Upload successed.",
"Remote file_id": "group1/M00/00/00/wKjzh0_xaR63RExnAAAaDqbNk5E1398.txt",
"Uploaded size": "6.0KB",
"Local file name": "test.txt",
"Storage IP": "192.168.243.133"
}
Advance
- Upload as URL
from pathlib import Path
p = Path('test.txt')
client = FastdfsClient(["dfs.waketzheng.top"])
url = client.upload_as_url(p.read_bytes(), p.suffix)
print(url)
# https://dfs.waketzheng.top/group1/M00/00/00/wKjzh0_xaR63RExnAAAaDqbNk5E1398.txt
- Download
save_to = 'local.txt'
client.download_to_file(save_to, 'group1/M00/00/00/wKjzh0_xaR63RExnAAAaDqbNk5E1398.txt')
- Delete
id_or_url = 'https://dfs.waketzheng.top/group1/M00/00/00/wKjzh0_xaR63RExnAAAaDqbNk5E1398.txt'
# id_or_url = 'group1/M00/00/00/wKjzh0_xaR63RExnAAAaDqbNk5E1398.txt'
client.delete_file(id_or_url)
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
fastdfs_client-1.2.0.tar.gz
(35.9 kB
view details)
Built Distribution
File details
Details for the file fastdfs_client-1.2.0.tar.gz
.
File metadata
- Download URL: fastdfs_client-1.2.0.tar.gz
- Upload date:
- Size: 35.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Darwin/20.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f076c6e426d8502311d6cd0717633afc28500c7080be25f648eb282b8398ea4c |
|
MD5 | c05ced4cba2a3df6f6e1a67a6d3e3f2b |
|
BLAKE2b-256 | c0d2fbb4f772382ab097eaa73f11f4d28eb50470a7bc300acdf3ef1da9496c77 |
File details
Details for the file fastdfs_client-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: fastdfs_client-1.2.0-py3-none-any.whl
- Upload date:
- Size: 38.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Darwin/20.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66c1956d1517e446c48275d7e5ca3b2c93e1dfb706f1d78bb18939c58f5f2cff |
|
MD5 | af137ec842b41b0d117c52a130becbbe |
|
BLAKE2b-256 | 9ca8ba0e219167488f4db973126eebf3e176efd8aa2a396e8f753be669ef18d1 |