import os
# 1. 导入FastDFS客户端扩展
from fdfs_client.client import Fdfs_client
# 2. 创建FastDFS客户端实例
client = Fdfs_client('client.conf')
def file_path(file_dir):
for root, dirs, files in os.walk(file_dir):
for per in files:
per = file_dir + '//' + per
# 3. 调用FastDFS客户端上传文件方法
ret = client.upload_by_filename(per)
context = per + " ==\t" + ret['Remote file_id'] + '\n'
with open(text_name, 'a', encoding='utf-8') as f:
f.write(context)
file_dir = 'E:\goods'
file_path(file_dir)
print("- end -") |
|