You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/01/29 19:48:23 UTC
android commit: [CB-2293] Fix typo bufferSize->bytesRead.
Updated Branches:
refs/heads/master 56cd24797 -> 2e20bb063
[CB-2293] Fix typo bufferSize->bytesRead.
Also adds a log statement to print out amount uploaded when an
IOException is thrown.
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/2e20bb06
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/2e20bb06
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/2e20bb06
Branch: refs/heads/master
Commit: 2e20bb063933a5cc27ae95b0ec70c59c5b9ae3b9
Parents: 56cd247
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jan 29 13:47:15 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jan 29 13:47:15 2013 -0500
----------------------------------------------------------------------
framework/src/org/apache/cordova/FileTransfer.java | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/2e20bb06/framework/src/org/apache/cordova/FileTransfer.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileTransfer.java b/framework/src/org/apache/cordova/FileTransfer.java
index c0bd1bd..783a71b 100644
--- a/framework/src/org/apache/cordova/FileTransfer.java
+++ b/framework/src/org/apache/cordova/FileTransfer.java
@@ -215,6 +215,8 @@ public class FileTransfer extends CordovaPlugin {
HttpURLConnection conn = null;
HostnameVerifier oldHostnameVerifier = null;
SSLSocketFactory oldSocketFactory = null;
+ int totalBytes = 0;
+ int fixedLength = -1;
try {
// Create return object
FileUploadResult result = new FileUploadResult();
@@ -320,7 +322,6 @@ public class FileTransfer extends CordovaPlugin {
int stringLength = extraBytes.length + midParams.length() + tailParams.length() + fileNameBytes.length;
Log.d(LOG_TAG, "String Length: " + stringLength);
- int fixedLength = -1;
if (sourceInputStream instanceof FileInputStream) {
fixedLength = (int) ((FileInputStream)sourceInputStream).getChannel().size() + stringLength;
progress.setLengthComputable(true);
@@ -363,13 +364,12 @@ public class FileTransfer extends CordovaPlugin {
// read file and write it into form...
int bytesRead = sourceInputStream.read(buffer, 0, bufferSize);
- long totalBytes = 0;
long prevBytesRead = 0;
while (bytesRead > 0) {
totalBytes += bytesRead;
result.setBytesSent(totalBytes);
- dos.write(buffer, 0, bufferSize);
+ dos.write(buffer, 0, bytesRead);
if (totalBytes > prevBytesRead + 102400) {
prevBytesRead = totalBytes;
Log.d(LOG_TAG, "Uploaded " + totalBytes + " of " + fixedLength + " bytes");
@@ -436,6 +436,7 @@ public class FileTransfer extends CordovaPlugin {
} catch (IOException e) {
JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, conn);
Log.e(LOG_TAG, error.toString(), e);
+ Log.e(LOG_TAG, "Failed after uploading " + totalBytes + " of " + fixedLength + " bytes.");
context.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, error));
} catch (JSONException e) {
Log.e(LOG_TAG, e.getMessage(), e);