The following API query:
/w/api.php?action=upload&format=json&filename=whatevs.jpg&stash=1&filesize=0&offset=0&chunk=...&token=7ff1207a75c6529a4fbb9414db128a0156f3993b%2B%5C
Produces the following:
<b>Warning</b>: fread(): Length parameter must be greater than 0 in <b>/var/www/html/w/includes/MimeMagic.php</b> on line <b>648</b>
&filesize=0&offset=0 seems to be the important part, and you must attempt a chunked upload with &chunk and not a simple one with &file.