The return value was the number of bytes left, it is supposed to be the number of bytes used.
Attach a file by drag & drop or click to upload