Dropbox API v2 - trying to upload file with files_upload() - throws TypeError

一曲冷凌霜 提交于 2019-12-04 03:04:24

From this documentation, it appears that the first argument to files_upload() needs to be a bytes object. Which means you got close with:

with open("/home/pi/Desktop/dbox/asd.txt", "rb") as f:
    dbx.files_upload(f, '/asd.txt', mute = True)

Try this instead (f.read() returns a bytes object):

with open("/home/pi/Desktop/dbox/asd.txt", "rb") as f:
    dbx.files_upload(f.read(), '/asd.txt', mute = True)

You could also try passing data.encode(whatever_encoding) instead of just data. I am not sure why this is not mentioned in the tutorial that you linked.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!