I have resolved my issue, it was my mistake. The file that was being uploaded had not been correctly downloaded from the origin source first. So i guess the code was attempting to upload a file containing 0 bytes or something similar.