# Fdfs_client py
The Python interface to the Fastdfs Ver 4.06.
## Installation
$ sudo python setup.py install
## Getting Started
1. import fdfs_client.client module
2. instantiate class Fdfs_client
3. call memeber functions
>>> from fdfs_client.client import *
>>> client = Fdfs_client('/etc/fdfs/client.conf')
>>> ret = client.upload_by_filename('test')
>>> ret
{'Group name':'group1','Status':'Upload successed.', 'Remote file_id':'group1/M00/00/00/
wKjzh0_xaR63RExnAAAaDqbNk5E1398.py','Uploaded size':'6.0KB','Local file name':'test'
, 'Storage IP':'192.168.243.133'}
## API Reference
Class Fdfs_client:
member functions:
* upload_by_filename(self, filename, meta_dict = None)
'''
Upload a file to Storage server.
arguments:
@filename: string, name of file that will be uploaded
@meta_dict: dictionary e.g.:{
'ext_name' : 'jpg',
'file_size' : '10240B',
'width' : '160px',
'hight' : '80px'
} meta_dict can be null
@return dict {
'Group name' : group_name,
'Remote file_id' : remote_file_id,
'Status' : 'Upload successed.',
'Local file name' : local_file_name,
'Uploaded size' : upload_size,
'Storage IP' : storage_ip
} if success else None
* upload_by_buffer(self, filebuffer, file_ext_name = None, meta_dict = None)
'''
Upload a buffer to Storage server.
arguments:
@filebuffer: string, buffer
@file_ext_name: string, file extend name
@meta_dict: dictionary e.g.:{
'ext_name' : 'jpg',
'file_size' : '10240B',
'width' : '160px',
'hight' : '80px'
}
@return dict {
'Group name' : group_name,
'Remote file_id' : remote_file_id,
'Status' : 'Upload successed.',
'Local file name' : '',
'Uploaded size' : upload_size,
'Storage IP' : storage_ip
}
'''
* upload_slave_by_filename(self, filename, remote_file_id, prefix_name, \
meta_dict = None)
'''
Upload slave file to Storage server.
arguments:
@filename: string, local file name
@remote_file_id: string, remote file id
@prefix_name: string
@meta_dict: dictionary e.g.:{
'ext_name' : 'jpg',
'file_size' : '10240B',
'width' : '160px',
'hight' : '80px'
}
@return dictionary {
'Status' : 'Upload slave successed.',
'Local file name' : local_filename,
'Uploaded size' : upload_size,
'Remote file id' : remote_file_id,
'Storage IP' : storage_ip
}
'''
* upload_slave_by_buffer(self, filebuffer, remote_file_id, \
meta_dict = None, file_ext_name = None)
'''
Upload slave file by buffer
arguments:
@filebuffer: string
@remote_file_id: string
@meta_dict: dictionary e.g.:{
'ext_name' : 'jpg',
'file_size' : '10240B',
'width' : '160px',
'hight' : '80px'
}
@return dictionary {
'Status' : 'Upload slave successed.',
'Local file name' : local_filename,
'Uploaded size' : upload_size,
'Remote file id' : remote_file_id,
'Storage IP' : storage_ip
}
'''
* upload_appender_by_filename(self, local_filename, meta_dict = None)
'''
Upload an appender file by filename.
arguments:
@local_filename: string
@meta_dict: dictionary e.g.:{
'ext_name' : 'jpg',
'file_size' : '10240B',
'width' : '160px',
'hight' : '80px'
} Notice: it can be null
@return dict {
'Group name' : group_name,
'Remote file_id' : remote_file_id,
'Status' : 'Upload successed.',
'Local file name' : '',
'Uploaded size' : upload_size,
'Storage IP' : storage_ip
}
'''
* upload_appender_by_buffer(self, filebuffer, file_ext_name = None, meta_dict = None)
'''
Upload a buffer to Storage server.
arguments:
@filebuffer: string
@file_ext_name: string, can be null
@meta_dict: dictionary, can be null
@return dict {
'Group name' : group_name,
'Remote file_id' : remote_file_id,
'Status' : 'Upload successed.',
'Local file name' : '',
'Uploaded size' : upload_size,
'Storage IP' : storage_ip
}
'''
* delete_file(self, remote_file_id)
'''
Delete a file from Storage server.
arguments:
@remote_file_id: string, file_id of file that is on storage server
@return tuple ('Delete file successed.', remote_file_id, storage_ip)
'''
* download_to_file(self, local_filename, remote_file_id, offset = 0, down_bytes = 0)
'''
Download a file from Storage server.
arguments:
@local_filename: string, local name of file
@remote_file_id: string, file_id of file that is on storage server
@offset: long
@down_bytes: long
@return dict {
'Remote file_id' : remote_file_id,
'Content' : local_filename,
'Download size' : downloaded_size,
'Storage IP' : storage_ip
}
'''
* download_to_buffer(self, remote_file_id, offset = 0, down_bytes = 0)
'''
Download a file from Storage server and store in buffer.
arguments:
@remote_file_id: string, file_id of file that is on storage server
@offset: long
@down_bytes: long
@return dict {
'Remote file_id' : remote_file_id,
'Content' : file_buffer,
'Download size' : downloaded_size,
'Storage IP' : storage_ip
}
'''
* list_one_group(self, group_name)
'''
List one group information.
arguments:
@group_name: string, group name will be list
@return Group_info, instance
'''
* list_all_groups(self)
'''
List all group information.
@return dictionary {
'Groups count' : group_count,
'Groups' : list of groups
}
'''
* list_servers(self, group_name, storage_ip = None)
'''
List all storage servers information in a group
arguments:
@group_name: string
@return dictionary {
'Group name' : group_name,
'Servers' : server list,
}
'''
* get_meta_data(self, remote_file_id)
'''
Get meta data of remote file.
arguments:
@remote_fileid: string, remote file id
@return dictionary, meta data
'''
* set_meta_data(self, remote_file_id, \
meta_dict, op_flag = STORAGE_SET_METADATA_FLAG_OVERWRITE)
'''
Set meta data of remote file.
arguments:
@remote_file_id: string
@meta_dict: dictionary
@op_flag: char, 'O' for overwrite, 'M' for merge
@return dictionary {
'Status' : status,
'Storage IP' : storage_ip
}
'''
* append_by_filename(self, local_filename, remote_fileid)
'''
Append a file of Storage server
arguments:
@local_filename: string
@remote_fileid: string
@return dict {
'Group name' : group_name,
'Remote file_id' : remote_file_id,
'Status' : 'Upload successed.',
'Local file name' : '',
'Uploaded size' : upload_size,
'Storage IP' : storage_ip
}
'''
* append_by_buffer(self, file_buffer, remote_fileid)
'''
Append a file of Storage server
arguments:
@file_buffer: string
@remote_fileid: string
@return dict {
'Group name' : group_name,
'Remote file_id' : remote_file_id,
没有合适的资源?快使用搜索试试~ 我知道了~
fdfs-client-py-master
共47个文件
py:28个
txt:6个
pkg-info:3个
需积分: 5 0 下载量 34 浏览量
2023-08-08
18:46:12
上传
评论
收藏 206KB ZIP 举报
温馨提示
fdfs_client-py-master修改版
资源推荐
资源详情
资源评论
收起资源包目录
fdfs_client-py-master.zip (47个子文件)
fdfs_client-py-master
CHANGES 1KB
setup.py 1KB
fdfs_client
utils.py 8KB
__init__.py 88B
fdfs_test.py 13KB
connection.py 7KB
fdfs_protol.py 9KB
storage_client.py 29KB
tracker_client.py 22KB
client.py 26KB
__pycache__
sendfilemodule.c 11KB
exceptions.py 324B
LICENSE 34KB
PKG-INFO 13KB
dist
fdfs_client_py-1.2.6-py3.6.egg 56KB
fdfs_client_py-1.2.6-py3.5.egg 57KB
build
bdist.win-amd64
egg
EGG-INFO
SOURCES.txt 447B
top_level.txt 12B
PKG-INFO 13KB
dependency_links.txt 1B
fdfs_client
utils.py 8KB
__init__.py 88B
fdfs_test.py 13KB
connection.py 7KB
fdfs_protol.py 9KB
storage_client.py 29KB
tracker_client.py 22KB
client.py 26KB
__pycache__
exceptions.py 324B
lib
fdfs_client
utils.py 8KB
__init__.py 88B
fdfs_test.py 13KB
connection.py 7KB
fdfs_protol.py 9KB
storage_client.py 29KB
tracker_client.py 22KB
client.py 26KB
exceptions.py 324B
INSTALL 98B
MANIFEST.in 98B
.gitignore 783B
setup.cfg 59B
fdfs_client_py.egg-info
SOURCES.txt 447B
top_level.txt 12B
PKG-INFO 13KB
dependency_links.txt 1B
README.md 10KB
共 47 条
- 1
资源评论
Jerry_qqxxw
- 粉丝: 2
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- QuestionTwo.java
- QuestionOne.java
- OA办公自动化管理系统(Struts1.2+Hibernate3.0+Spring2+DWR).rar
- 简历-求职简历-word-文件-简历模版免费分享-应届生-高颜值简历模版-个人简历模版-简约大气-大学生在校生-求职-实习
- 南京邮电大学数学实验:熟练掌握 Matlab 软件的基本命令和操作
- 简历-求职简历-word-文件-简历模版免费分享-应届生-高颜值简历模版-个人简历模版-简约大气-大学生在校生-求职-实习
- 2017校招真题校园招聘真题算法题(37道)Python源码.zip
- 基于单片机protues仿真的多功能自动饮水机系统设计(仿真图、源代码、演示视频)
- 论文《一种修复流程挖掘事件日志中缺失活动标签的深度学习方法》翻译
- 智慧电厂相关资料发电控制的方式
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功