Return-Path: X-Original-To: apmail-cordova-issues-archive@minotaur.apache.org Delivered-To: apmail-cordova-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3CCFA10EAD for ; Tue, 28 Jan 2014 23:25:18 +0000 (UTC) Received: (qmail 59815 invoked by uid 500); 28 Jan 2014 23:25:12 -0000 Delivered-To: apmail-cordova-issues-archive@cordova.apache.org Received: (qmail 59789 invoked by uid 500); 28 Jan 2014 23:25:11 -0000 Mailing-List: contact issues-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list issues@cordova.apache.org Received: (qmail 59755 invoked by uid 99); 28 Jan 2014 23:25:10 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jan 2014 23:25:10 +0000 Date: Tue, 28 Jan 2014 23:25:10 +0000 (UTC) From: "ASF subversion and git services (JIRA)" To: issues@cordova.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CB-2421) On Windows 8 , FileTransfer.upload returns wrong FileUploadResult MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-2421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13884904#comment-13884904 ] ASF subversion and git services commented on CB-2421: ----------------------------------------------------- Commit be44194066f20b1b927608005f76afb7d11994d6 in branch refs/heads/dev 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 > > 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)