ItChat
ItChat copied to clipboard
upload file 支持 filelike-object
目前的upload_file只支持文件目录上传,对于储存在内存中的数据上传则不支持(例如BytesIO),希望能将fileDir参数扩展到支持广泛的file-like object,直接使用read()读取数据
@AZLisme 好,1.3.0里面我会增加这个功能。
@AZLisme 已更新,你可以在这里看到最新的commit。
下面是测试程序:
import itchat
itchat.auto_login(True)
with open('t.pdf', 'rb') as f:
r = itchat.send_file('test.pdf', 'filehelper', file_=f)
# equals to:
# r = itchat.send_file('t.pdf', 'filehelper')
print(r)
with open('t.png', 'rb') as f:
r = itchat.send_image(f, 'filehelper')
# equals to:
# r = itchat.send_image('t.png', 'filehelper')
print(r)
with open('t.mp4', 'rb') as f:
r = itchat.send_video(f, 'filehelper')
# equals to:
# r = itchat.send_video('t.mp4', 'filehelper')
print(r)
itchat.run()
👍