Search This Blog

Sunday, September 9, 2012

Python, Dropbox API File Size Mismatch Bug Under Window

The following Python code will simply upload a file using Dropbox API. This works will under Linux. However, the code will break if you use it under Windows platform.

Do you see the bug?

The bug is at line:
f = open('working-draf.txt')

This may or may not work. Because it is not open as a binary file. Dropbox has a utility that will complain how many bytes it read is not equal to the file you are trying to send with the client.puf_file() call.

To fix it, simple put:
f = open('working-draft.txt', 'rb')

Open the file in binary mode ! This will get rid of file size mismatch assertion.

Happy Dropboxing.

No comments: