You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2014/02/11 00:23:33 UTC
[jira] [Commented] (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:comment-tabpanel&focusedCommentId=13897227#comment-13897227 ]
ASF subversion and git services commented on CB-2421:
-----------------------------------------------------
Commit be44194066f20b1b927608005f76afb7d11994d6 in branch refs/heads/master from [~purplecabbage]
[ https://git-wip-us.apache.org/repos/asf?p=cordova-plugin-file-transfer.git;h=be44194 ]
CB-2421 explicitly write the bytesSent,responseCode,result to the FileUploadResult pending release of cordova-plugin-file dependency, added some sanity checks for callbacks
> 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)