Skip to main content

Python Implement for FastDFS Client

Project description

fastdfs-client-python

Python Versions LatestVersionInPypi Ruff Mypy coverage pre-commit.ci status

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

from pathlib import Path

p = Path('test.txt')
url = FastdfsClient("192.168.243.133").upload_as_url(p.read_bytes(), p.suffix)
print(url)
# http://192.168.243.133/group1/M00/00/00/wKjzh0_xaR63RExnAAAaDqbNk5E1398.txt

Project details


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.1.4.tar.gz (35.5 kB view details)

Uploaded Source

Built Distribution

fastdfs_client-1.1.4-py3-none-any.whl (37.8 kB view details)

Uploaded Python 3

File details

Details for the file fastdfs_client-1.1.4.tar.gz.

File metadata

  • Download URL: fastdfs_client-1.1.4.tar.gz
  • Upload date:
  • Size: 35.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.8 Darwin/20.6.0

File hashes

Hashes for fastdfs_client-1.1.4.tar.gz
Algorithm Hash digest
SHA256 ba7bbe22d0377b44f9800ce2293c4b9a5e26597cf9d39e7e74c641e2d64d7344
MD5 dfc83f4d61d97dd6dfc940f777486e6a
BLAKE2b-256 76e3b04107598ccd80bf5aec9735e4277dc97fa8fa0268b2d5cf084d5f1ad77e

See more details on using hashes here.

File details

Details for the file fastdfs_client-1.1.4-py3-none-any.whl.

File metadata

  • Download URL: fastdfs_client-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 37.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.8 Darwin/20.6.0

File hashes

Hashes for fastdfs_client-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e8c58cbbad07accbae960a77bc2586916989bf8246667efffab2150dc0ebdad4
MD5 08b860fc4cdc22ab00f43d241564b26d
BLAKE2b-256 47500bb7f79b8b9e669dc353d75e7aba44282bfb066364f835ce1adc8f0eedb2

See more details on using hashes here.

Supported by

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