hay86 / fdfs_client-py

fastdfs python client compatible with ver 4.0.6
GNU General Public License v3.0
106 stars 89 forks source link

python3.6 the following code cant run, error: #24

Open Achillesxu opened 5 years ago

Achillesxu commented 5 years ago
client = Fdfs_client(settings.FAST_DFS_CONFIG, poolclass=ConnectionPool)
with open('/Users/achilles_xushy/Downloads/Sierra.jpg') as pf:
    buf = pf.read(2*2**20)
    ret = client.upload_by_buffer(buf, 'jpg')
    print(ret)
    for i in range(3):
        ret = client.append_by_buffer(buf, ret['Remote file_id'])
        print(ret)

run that code, exception as following(linux, ubuntu):

{'Group name': b'group1', 'Remote file_id': b'group1/M00/14/04/wKjScV0-1k-Af6_pACAAAKHnBIk112.jpg', 'Status': 'Upload successed.', 'Local file name': '', 'Uploaded size': '2.00MB', 'Storage IP': b'192.168.210.113'} Traceback (most recent call last): File "/home/media/Python3.6.5/lib/python3.6/site-packages/fdfs_client/connection.py", line 196, in tcp_send_data conn._sock.sendall(bytes_stream) ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "scratch_16.py", line 19, in ret = client.append_by_buffer(buf, ret['Remote file_id']) File "/home/media/Python3.6.5/lib/python3.6/site-packages/fdfs_client/client.py", line 512, in append_by_buffer 1 from fdfs_client.client import * return store.storage_append_by_buffer(tc, store_serv, file_buffer, appended_filename) File "/home/media/Python3.6.5/lib/python3.6/site-packages/fdfs_client/storage_client.py", line 498, in storage_append_by_buffer appended_filename) File "/home/media/Python3.6.5/lib/python3.6/site-packages/fdfs_client/storage_client.py", line 468, in _storage_do_append_file tcp_send_data(store_conn, file_buffer) File "/home/media/Python3.6.5/lib/python3.6/site-packages/fdfs_client/connection.py", line 198, in tcp_send_data raise ConnectionError('[-] Error: while writting to socket: (%s)' % e.args) TypeError: not all arguments converted during string formatting