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

时间:2016-11-21 04:53:02

标签: python

我尝试过使用Dropbox API在Python上传图片的多种方法,而且非常复杂。

    public class Content
    {

        public async void Delay1()
        {
            await Task.Delay(5000);
            Console.WriteLine("hello");
        }
        public async void Delay2()
        {
            await Task.Delay(5000);
            Console.WriteLine("hello");
        }
        public async void Delay3()
        {
            await Task.Delay(5000);
            Console.WriteLine("hello");
        }
        public void Print()
        {
            Delay1();
            Delay2();
            Delay3();
        }
    }

由于files_upload需要字节,路径我不知道如何去做。 我总是得到这个错误

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)

有什么我不明白的吗?

1 个答案:

答案 0 :(得分:0)

只需使用

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