[英]how to upload a picture through dropbox with python
I have tried multiple ways to upload pictures in Python with the Dropbox API and it's very complicated. 我尝试了多种方式使用Dropbox API在Python中上传图片,这非常复杂。
bot.command(pass_context=True)
async def upload(ctx, *, message):
await bot.say("Downloading the file from the link, hang on...")
url = str(message)
wget.download(url)
await bot.say("Done. Now uploading it to Dropbox...")
o = os.path.basename(url)
with open(o, "rb") as imageFile:
f = imageFile.read()
b = bytearray(f)
dbx.files_upload(b, '/' + o)
Since the files_upload requires bytes, path I have no clue how to go about it. 由于files_upload需要字节,因此我不知道如何进行操作。 I always get this error
我总是得到这个错误
TypeError: expected request_binary as binary type, got <class 'bytearray'>
is there something i dont get? 我有没有得到的东西?
只是使用
dbx.files_upload(imageFile.read(), '/' + o)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.