美文网首页
Python fastDFS 安装使用

Python fastDFS 安装使用

作者: 富竹 | 来源:发表于2020-04-07 21:51 被阅读0次

安装步骤

  1. 解压fdfs_client-py-master安装包
  2. 打开setup.py,注释掉34、35行
  3. 打开storage_client.py,注释掉12行
  4. 运行python setup.py install

设置服务器地址

配置文件里修改FastDFS服务的IP地址

tracker_server=192.168.8.20:22122

基本使用

from fdfs_client.client import Fdfs_client

# 读取配置文件
client_conf_path = r'C:\Users\admin\Desktop\client.conf'
client = Fdfs_client(client_conf_path)

# 上传文件,生成文件url
upload_file = 'mm.jpg'
ret = client.upload_by_filename(upload_file)
file_url = ret['Remote file_id'].replace('\\', '/')

# 删除文件
client.delete_file(file_url)

相关文章

网友评论

      本文标题:Python fastDFS 安装使用

      本文链接:https://www.haomeiwen.com/subject/dywophtx.html