繁体   English   中英

使用dropbox api上传块

[英]upload chunks using dropbox api

我正在使用Dropbox API以块的形式上传文件。 但是下面的代码卡在uploader.upload_chunked()上。 可能是什么原因?

此外,有没有办法知道在后台发生了什么,如上传了这么多块,仍然上传,接收上传的块和其他信息的时间? 可以使用线程来上传这些块,假设API采取措施以正确的顺序组装块,或者是否我们必须处理有序的组装?

import dropbox
size = 941   
access_token = 'xxx'
client = dropbox.client.DropboxClient(access_token)
to_upload_file = open('dummy.txt','r')

uploader = client.get_chunked_uploader(to_upload_file,size)

print 'uploading ', size
while uploader.offset < size :
        try:
                upload = uploader.upload_chunked(chunk_size=100)  
                print '100 bytes of chunk sent.'
        except dropbox.rest.ErrorResponse,e:
                print 'something went wrong'      
uploader.finish('/dummy.txt')

编辑
size = 941 - >要上载的文件的大小
upload=uploader.upload_chunked(chunk_size=100) - > chunk_size从默认更改为100字节
print'100 bytes of chunk sent' - >打印语句包括在内

我有同样的问题,所以我在Dropbox的开发者论坛中问他们建议upload_chunk (DropboxClient的成员函数,而不是ChunkedUploader中的成员函数)可以满足我们的要求

upload_chunked上传整个文件(一次一个块),因此除非发生错误,否则上传代码应该只在文件上传后到达print语句一次。

有关upload_chunked的文档,请参阅https://www.dropbox.com/developers/core/docs/python#ChunkedUploader.upload_chunked

暂无
暂无

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

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