0
votes

I am trying to do chunk upload on Dropbox using Python. My problem is that I don't necessary have access to the file, I can't always get a file handler.

I always have a string containing the chunk I need to upload. But the problem is that client.upload_chunk requires a file like object, and I don't understand how the /chunked_upload on the HTTP API works. How do you precise the filename?

Here is how I do it right now:

e, upload_id = self.client.upload_chunk(chunk, len(chunk), offset)
print "Uploaded: ", e, " upload_id: ", upload_id

This does not raise any error and print the size and upload_id but nothing appears on my dropbox.

What is happening? Any idea on how to do this?

1
The low-level API has upload_chunk() but seems to be missing commit_chunked_upload(). Looking at the ChunkedUploader source code might help (e.g. sourcegraph.com/github.com/sourcegraph/dropbox/symbols/python/… ) - Armin Rigo
I think I can use client.upload_chunk() my problem beeing how do you precise the filename?? Because this line does what I want self.client.upload_chunk(StringIO(self.last_block), next_chunk_size, self.offset, self.upload_id) but still how do precise which file you are updating? - Manny42
dropbox.com/developers/core/docs/python#ChunkedUploader : you give the file name in the finish() call. - Armin Rigo

1 Answers

0
votes

I believe you can just use ChunkedUploader and pass in a StringIO.