Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.0
-
None
Description
When reporting success, the existing code attempts to read the original file as a string and report it as a response (instead of the server's response).
It also calls a non-existent constructor new FileUploadResult(basicProperties.size, code, fileContent).
When the uploaded file is not textual (e.g. a JPEG image), the current code fails altogether because dataReader.readString throws an exception.
Here is a possible correction:
Old Code:
storageFile.getBasicPropertiesAsync().done(function (basicProperties) {
Windows.Storage.FileIO.readBufferAsync(storageFile).done(function (buffer)
);
}, function () {
error(FileTransferError.INVALID_URL_ERR);
});
Correction:
storageFile.getBasicPropertiesAsync().done(function (basicProperties) {
var res = new FileUploadResult();
res.bytesSent=basicProperties.size;
res.responseCode=response.status;
res.response=response.responseText;
win(res);
});
Possible a more elegant correction would be to add the missing constructor for FileUploadResult