You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Jesse MacFadyen (JIRA)" <ji...@apache.org> on 2014/01/29 00:31:19 UTC
[jira] [Resolved] (CB-2421) On Windows 8 , FileTransfer.upload
returns wrong FileUploadResult
[ https://issues.apache.org/jira/browse/CB-2421?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jesse MacFadyen resolved CB-2421.
---------------------------------
Resolution: Fixed
Fix Version/s: 2.4.0
> On Windows 8 , FileTransfer.upload returns wrong FileUploadResult
> -----------------------------------------------------------------
>
> Key: CB-2421
> URL: https://issues.apache.org/jira/browse/CB-2421
> Project: Apache Cordova
> Issue Type: Bug
> Components: Plugin File Transfer, Windows 8
> Affects Versions: 2.4.0
> Reporter: Youval Bronicki
> Assignee: Jesse MacFadyen
> Fix For: 2.4.0
>
>
> 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) {
> var dataReader = Windows.Storage.Streams.DataReader.fromBuffer(buffer);
> var fileContent = dataReader.readString(buffer.length);
> dataReader.close();
> win(new FileUploadResult(basicProperties.size, code, fileContent));
> });
> }, 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
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)