Fix a bug making file upload horribly slow.

The bug was introduced during the fix of #257

Signed-off-by: Clement Escoffier <clement.escoffier@gmail.com>