# Fdfs_client py
The Python interface to the Fastdfs Ver 4.06.
本项目fork 自 https://pypi.org/project/py3Fdfs/#files
因为作者多年没有更新过了,作为独立项目维护
解决了 在celery 中调用出现的 调用类型错误
## 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,
'Status' : 'Upload successed.',
'Local file name' : '',
'Uploaded size' : upload_size,
'Storage IP' : storage_ip
}
'''
* truncate_file(self, truncated_filesize, appender_fileid)
'''
Truncate file in Storage server.
arguments:
@truncated_filesize: long
@appender_fileid: remote_fileid
@return: dictionary {
'Status' : 'Truncate successed.',
'Storage IP' : storage_ip
}
'''
* modify_by_filename(self, filename, appender_fileid, offset = 0)
'''
Modify a file in Storage server by filename.
arguments:
@filename: string, local file name
@offset: long, file offset
@appender_fileid: string, remote file id
@return: dictionary {
'Status' : 'Modify successed.',
'Storage IP' : storage_ip
}
'''
* modify_by_buffer(self, filebuffer, appender_fileid, offset = 0)
'''
Modify a file in Storage server by buffer.
arguments:
@filebuffer: string, file buffer
@offset: long, file offset
@appender_fileid: string, remote file id
@return: dictionary {
'Status' : 'Modify successed.',
'Storage IP' : storage_ip
}
'''
### Connection Pools
Behind the scenes, fdfs_client-py uses a connection pool to manage connections to
sets of tracker server and storage server.
## Versioning scheme
fdfs_client-py ver 1.2.7b support client protol of Fastdfs ver 4.06.
Python must be ver 2.6 later.
Author
------
fdfs_client-py is developed and maintained by scott yuan (scottzer8@gmail.com)
fdfs_client-py is bug fixed and maintained by hay86
It can be found here: http://github.com/hay86/fdfs_client-py
Special thanks to:
* Andy Mccurdy, author of redis-py, referenced his code.
* g.rodola, author sendfile module for python, g.rodola@gmail.com
Raw data
{
"_id": null,
"home_page": "http://github.com/renoyuan/easyPyFdfs",
"name": "easyPyFdfs",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "Fastdfs, Distribute File System",
"author": "renoyuan",
"author_email": "renoyuan@foxmail.com",
"download_url": "https://files.pythonhosted.org/packages/e5/98/0df22753d5d370cddd5ff5af7c9c75a9c457dca30452d169c5030052fe26/easyPyFdfs-3.0.0.tar.gz",
"platform": null,
"description": "# Fdfs_client py\r\n\r\nThe Python interface to the Fastdfs Ver 4.06.\r\n\r\n\u672c\u9879\u76eefork \u81ea https://pypi.org/project/py3Fdfs/#files\r\n\u56e0\u4e3a\u4f5c\u8005\u591a\u5e74\u6ca1\u6709\u66f4\u65b0\u8fc7\u4e86\uff0c\u4f5c\u4e3a\u72ec\u7acb\u9879\u76ee\u7ef4\u62a4\r\n\u89e3\u51b3\u4e86 \u5728celery \u4e2d\u8c03\u7528\u51fa\u73b0\u7684 \u8c03\u7528\u7c7b\u578b\u9519\u8bef\r\n\r\n## Installation\r\n\r\n $ sudo python setup.py install\r\n\r\n## Getting Started\r\n\t1. import fdfs_client.client module\r\n\t2. instantiate class Fdfs_client\r\n\t3. call memeber functions\r\n\r\n >>> from fdfs_client.client import *\r\n >>> client = Fdfs_client('/etc/fdfs/client.conf')\r\n >>> ret = client.upload_by_filename('test')\r\n\t>>> ret\r\n\t{'Group name':'group1','Status':'Upload successed.', 'Remote file_id':'group1/M00/00/00/\r\n \twKjzh0_xaR63RExnAAAaDqbNk5E1398.py','Uploaded size':'6.0KB','Local file name':'test'\r\n\t\t, 'Storage IP':'192.168.243.133'}\r\n\r\n## API Reference\r\n\r\nClass Fdfs_client:\r\n\r\nmember functions:\r\n\r\n* upload_by_filename(self, filename, meta_dict = None)\r\n '''\r\n Upload a file to Storage server.\r\n arguments:\r\n @filename: string, name of file that will be uploaded\r\n @meta_dict: dictionary e.g.:{\r\n 'ext_name' : 'jpg',\r\n 'file_size' : '10240B',\r\n 'width' : '160px',\r\n 'hight' : '80px'\r\n } meta_dict can be null\r\n @return dict {\r\n 'Group name' : group_name,\r\n 'Remote file_id' : remote_file_id,\r\n 'Status' : 'Upload successed.',\r\n 'Local file name' : local_file_name,\r\n 'Uploaded size' : upload_size,\r\n 'Storage IP' : storage_ip\r\n } if success else None\r\n\r\n* upload_by_buffer(self, filebuffer, file_ext_name = None, meta_dict = None)\r\n '''\r\n Upload a buffer to Storage server.\r\n arguments:\r\n @filebuffer: string, buffer\r\n @file_ext_name: string, file extend name\r\n @meta_dict: dictionary e.g.:{\r\n 'ext_name' : 'jpg',\r\n 'file_size' : '10240B',\r\n 'width' : '160px',\r\n 'hight' : '80px'\r\n }\r\n @return dict {\r\n 'Group name' : group_name,\r\n 'Remote file_id' : remote_file_id,\r\n 'Status' : 'Upload successed.',\r\n 'Local file name' : '',\r\n 'Uploaded size' : upload_size,\r\n 'Storage IP' : storage_ip\r\n }\r\n '''\r\n\r\n* upload_slave_by_filename(self, filename, remote_file_id, prefix_name, \\\r\n meta_dict = None)\r\n '''\r\n Upload slave file to Storage server.\r\n arguments:\r\n @filename: string, local file name\r\n @remote_file_id: string, remote file id\r\n @prefix_name: string\r\n @meta_dict: dictionary e.g.:{\r\n 'ext_name' : 'jpg',\r\n 'file_size' : '10240B',\r\n 'width' : '160px',\r\n 'hight' : '80px'\r\n }\r\n @return dictionary {\r\n 'Status' : 'Upload slave successed.',\r\n 'Local file name' : local_filename,\r\n 'Uploaded size' : upload_size,\r\n 'Remote file id' : remote_file_id,\r\n 'Storage IP' : storage_ip\r\n }\r\n '''\r\n\r\n* upload_slave_by_buffer(self, filebuffer, remote_file_id, \\\r\n meta_dict = None, file_ext_name = None)\r\n '''\r\n Upload slave file by buffer\r\n arguments:\r\n @filebuffer: string\r\n @remote_file_id: string\r\n @meta_dict: dictionary e.g.:{\r\n 'ext_name' : 'jpg',\r\n 'file_size' : '10240B',\r\n 'width' : '160px',\r\n 'hight' : '80px'\r\n }\r\n @return dictionary {\r\n 'Status' : 'Upload slave successed.',\r\n 'Local file name' : local_filename,\r\n 'Uploaded size' : upload_size,\r\n 'Remote file id' : remote_file_id,\r\n 'Storage IP' : storage_ip\r\n }\r\n '''\r\n\r\n* upload_appender_by_filename(self, local_filename, meta_dict = None)\r\n '''\r\n Upload an appender file by filename.\r\n arguments:\r\n @local_filename: string\r\n @meta_dict: dictionary e.g.:{\r\n 'ext_name' : 'jpg',\r\n 'file_size' : '10240B',\r\n 'width' : '160px',\r\n 'hight' : '80px'\r\n } Notice: it can be null\r\n @return dict {\r\n 'Group name' : group_name,\r\n 'Remote file_id' : remote_file_id,\r\n 'Status' : 'Upload successed.',\r\n 'Local file name' : '',\r\n 'Uploaded size' : upload_size,\r\n 'Storage IP' : storage_ip\r\n\t }\r\n '''\r\n\r\n* upload_appender_by_buffer(self, filebuffer, file_ext_name = None, meta_dict = None)\r\n '''\r\n Upload a buffer to Storage server.\r\n arguments:\r\n @filebuffer: string\r\n @file_ext_name: string, can be null\r\n @meta_dict: dictionary, can be null\r\n @return dict {\r\n 'Group name' : group_name,\r\n 'Remote file_id' : remote_file_id,\r\n 'Status' : 'Upload successed.',\r\n 'Local file name' : '',\r\n 'Uploaded size' : upload_size,\r\n 'Storage IP' : storage_ip\r\n }\r\n '''\r\n\r\n* delete_file(self, remote_file_id)\r\n '''\r\n Delete a file from Storage server.\r\n arguments:\r\n @remote_file_id: string, file_id of file that is on storage server\r\n @return tuple ('Delete file successed.', remote_file_id, storage_ip)\r\n '''\r\n\r\n* download_to_file(self, local_filename, remote_file_id, offset = 0, down_bytes = 0)\r\n '''\r\n Download a file from Storage server.\r\n arguments:\r\n @local_filename: string, local name of file \r\n @remote_file_id: string, file_id of file that is on storage server\r\n\t @offset: long\r\n\t @down_bytes: long\r\n @return dict {\r\n 'Remote file_id' : remote_file_id,\r\n 'Content' : local_filename,\r\n 'Download size' : downloaded_size,\r\n 'Storage IP' : storage_ip\r\n }\r\n '''\r\n\r\n* download_to_buffer(self, remote_file_id, offset = 0, down_bytes = 0)\r\n '''\r\n Download a file from Storage server and store in buffer.\r\n arguments:\r\n\t @remote_file_id: string, file_id of file that is on storage server\r\n \t @offset: long\r\n\t @down_bytes: long\r\n @return dict {\r\n 'Remote file_id' : remote_file_id,\r\n 'Content' : file_buffer,\r\n 'Download size' : downloaded_size,\r\n 'Storage IP' : storage_ip\r\n }\r\n '''\r\n\r\n* list_one_group(self, group_name)\r\n '''\r\n List one group information.\r\n arguments:\r\n @group_name: string, group name will be list\r\n @return Group_info, instance\r\n '''\r\n\r\n* list_all_groups(self)\r\n '''\r\n List all group information.\r\n @return dictionary {\r\n 'Groups count' : group_count,\r\n 'Groups' : list of groups\r\n }\r\n '''\r\n\r\n* list_servers(self, group_name, storage_ip = None)\r\n '''\r\n List all storage servers information in a group\r\n arguments:\r\n @group_name: string\r\n @return dictionary {\r\n 'Group name' : group_name,\r\n 'Servers' : server list,\r\n }\r\n '''\r\n\r\n* get_meta_data(self, remote_file_id)\r\n '''\r\n Get meta data of remote file.\r\n arguments:\r\n @remote_fileid: string, remote file id\r\n @return dictionary, meta data\r\n '''\r\n\r\n* set_meta_data(self, remote_file_id, \\\r\n meta_dict, op_flag = STORAGE_SET_METADATA_FLAG_OVERWRITE)\r\n '''\r\n Set meta data of remote file.\r\n arguments:\r\n @remote_file_id: string\r\n @meta_dict: dictionary\r\n @op_flag: char, 'O' for overwrite, 'M' for merge\r\n @return dictionary {\r\n 'Status' : status,\r\n 'Storage IP' : storage_ip\r\n }\r\n '''\r\n\r\n* append_by_filename(self, local_filename, remote_fileid)\r\n '''\r\n Append a file of Storage server\r\n arguments:\r\n @local_filename: string\r\n \t @remote_fileid: string\r\n @return dict {\r\n 'Group name' : group_name,\r\n 'Remote file_id' : remote_file_id,\r\n 'Status' : 'Upload successed.',\r\n 'Local file name' : '',\r\n 'Uploaded size' : upload_size,\r\n 'Storage IP' : storage_ip\r\n }\r\n '''\r\n\r\n* append_by_buffer(self, file_buffer, remote_fileid)\r\n '''\r\n Append a file of Storage server\r\n arguments:\r\n @file_buffer: string\r\n \t @remote_fileid: string\r\n @return dict {\r\n 'Group name' : group_name,\r\n 'Remote file_id' : remote_file_id,\r\n 'Status' : 'Upload successed.',\r\n 'Local file name' : '',\r\n 'Uploaded size' : upload_size,\r\n 'Storage IP' : storage_ip\r\n }\r\n '''\r\n\r\n* truncate_file(self, truncated_filesize, appender_fileid)\r\n '''\r\n Truncate file in Storage server.\r\n arguments:\r\n @truncated_filesize: long\r\n @appender_fileid: remote_fileid\r\n @return: dictionary {\r\n 'Status' : 'Truncate successed.',\r\n 'Storage IP' : storage_ip\r\n }\r\n '''\r\n\t \r\n* modify_by_filename(self, filename, appender_fileid, offset = 0)\r\n '''\r\n Modify a file in Storage server by filename.\r\n arguments:\r\n @filename: string, local file name\r\n @offset: long, file offset\r\n @appender_fileid: string, remote file id\r\n @return: dictionary {\r\n 'Status' : 'Modify successed.',\r\n 'Storage IP' : storage_ip\r\n }\r\n '''\r\n\r\n* modify_by_buffer(self, filebuffer, appender_fileid, offset = 0)\r\n '''\r\n Modify a file in Storage server by buffer.\r\n arguments:\r\n @filebuffer: string, file buffer\r\n @offset: long, file offset\r\n @appender_fileid: string, remote file id\r\n @return: dictionary {\r\n 'Status' : 'Modify successed.',\r\n 'Storage IP' : storage_ip\r\n }\r\n '''\r\n\r\n### Connection Pools\r\n\r\nBehind the scenes, fdfs_client-py uses a connection pool to manage connections to\r\nsets of tracker server and storage server.\r\n\r\n\r\n## Versioning scheme\r\n\r\nfdfs_client-py ver 1.2.7b support client protol of Fastdfs ver 4.06.\r\nPython must be ver 2.6 later.\r\n\r\nAuthor\r\n------\r\n\r\nfdfs_client-py is developed and maintained by scott yuan (scottzer8@gmail.com)\r\n\r\nfdfs_client-py is bug fixed and maintained by hay86\r\n\r\nIt can be found here: http://github.com/hay86/fdfs_client-py\r\n\r\nSpecial thanks to:\r\n\r\n* Andy Mccurdy, author of redis-py, referenced his code.\r\n* g.rodola, author sendfile module for python, g.rodola@gmail.com\r\n\r\n",
"bugtrack_url": null,
"license": "GPLV3",
"summary": "Python3 and Python2 client for Fastdfs",
"version": "3.0.0",
"project_urls": {
"Homepage": "http://github.com/renoyuan/easyPyFdfs"
},
"split_keywords": [
"fastdfs",
" distribute file system"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "725614cae860788ac864d8906398f32b8a72df1b7bba89d8ab77b20eec7adc84",
"md5": "786e3474e208cd0a8b9084245e5f1785",
"sha256": "095d7117dfa5dd83da334d35ca3f34cd92c213e74655777cb26278321147da35"
},
"downloads": -1,
"filename": "easyPyFdfs-3.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "786e3474e208cd0a8b9084245e5f1785",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 37385,
"upload_time": "2024-04-29T06:03:06",
"upload_time_iso_8601": "2024-04-29T06:03:06.605778Z",
"url": "https://files.pythonhosted.org/packages/72/56/14cae860788ac864d8906398f32b8a72df1b7bba89d8ab77b20eec7adc84/easyPyFdfs-3.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e5980df22753d5d370cddd5ff5af7c9c75a9c457dca30452d169c5030052fe26",
"md5": "e8c81e73567069ae7a493b2147e999e0",
"sha256": "066047c6f10aaff9d7310d561373040a9698ba682e2ee5331156c260123b75ec"
},
"downloads": -1,
"filename": "easyPyFdfs-3.0.0.tar.gz",
"has_sig": false,
"md5_digest": "e8c81e73567069ae7a493b2147e999e0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 35511,
"upload_time": "2024-04-29T06:03:09",
"upload_time_iso_8601": "2024-04-29T06:03:09.025187Z",
"url": "https://files.pythonhosted.org/packages/e5/98/0df22753d5d370cddd5ff5af7c9c75a9c457dca30452d169c5030052fe26/easyPyFdfs-3.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-29 06:03:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "renoyuan",
"github_project": "easyPyFdfs",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "easypyfdfs"
}