[windows] Fix js error "The parameter is incorrect" (#199)

<!--
Please make sure the checklist boxes are all checked before submitting the PR. The checklist
is intended as a quick reference, for complete details please see our Contributor Guidelines:

http://cordova.apache.org/contribute/contribute_guidelines.html

Thanks!
-->

### Platforms affected
windows

### What does this PR do?
Fix js error "The parameter is incorrect" when download progress is 0 in error handler

### What testing has been done on this change?
Manual testing

### Checklist
- [ ] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
- [ ] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
- [ ] Added automated test coverage as appropriate for this change.
This commit is contained in:
Trong Tran
2018-10-02 03:45:08 +07:00
committed by Jan Piotrowski
parent 2e4539d406
commit 6c99dfa8d9

View File

@@ -499,6 +499,10 @@ exec(win, fail, 'FileTransfer', 'upload',
if (!response) {
resolve(new FTErr(FTErr.CONNECTION_ERR, source, target));
} else {
if (download.progress.bytesReceived === 0) {
resolve(new FTErr(FTErr.FILE_NOT_FOUND_ERR, source, target, response.statusCode, null, error));
return;
}
var reader = new Windows.Storage.Streams.DataReader(download.getResultStreamAt(0));
reader.loadAsync(download.progress.bytesReceived).then(function (bytesLoaded) {
var payload = reader.readString(bytesLoaded);