繁体   English   中英

如何使用python通过Dropbox上传图片

[英]how to upload a picture through dropbox with python

我尝试了多种方式使用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)

由于files_upload需要字节,因此我不知道如何进行操作。 我总是得到这个错误

TypeError: expected request_binary as binary type, got <class 'bytearray'>

我有没有得到的东西?

只是使用

dbx.files_upload(imageFile.read(), '/' + o)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM