Rewrite UploadData to honour both filename and mode
Rewrite UploadData to honour both filename and mode

UploadData works incorrectly if both filename and mode
are specified. This patch fixes this issue.

If filename is specified, and the file does not exist,
the file is then created.

Signed-off-by: Bhimanavajjula Aditya <07def62c7e98682cea1cc301939be6abb8e2f18f@google.com>
Signed-off-by: Klaus Aehlig <4ce51de36d9068cd7db2eec1151e0f3f95419008@google.com>
Reviewed-by: Klaus Aehlig <4ce51de36d9068cd7db2eec1151e0f3f95419008@google.com>

onponomarev/ganeti,mbakke/ganeti,mbakke/ganeti,andir/ganeti,leshchevds/ganeti,ganeti/ganeti,andir/ganeti,onponomarev/ganeti,leshchevds/ganeti,andir/ganeti,leshchevds/ganeti,ganeti/ganeti,mbakke/ganeti,ganeti/ganeti