incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject docs commit: Update docs for FileTransfer to include abort() and onprogress.
Date Wed, 24 Oct 2012 18:53:24 GMT
Updated Branches:
  refs/heads/master 15eb10593 -> 24e3ba9ce


Update docs for FileTransfer to include abort() and onprogress.

-Also tweaked section on headers to mention Android support.
-Fixes https://issues.apache.org/jira/browse/CB-1704


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/commit/24e3ba9c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/tree/24e3ba9c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/diff/24e3ba9c

Branch: refs/heads/master
Commit: 24e3ba9cee0f5520883dbfb1438f565546c7f52e
Parents: 15eb105
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Wed Oct 24 14:52:08 2012 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Wed Oct 24 14:53:19 2012 -0400

----------------------------------------------------------------------
 .../edge/cordova/file/filetransfer/filetransfer.md |   56 +++++++++++---
 .../file/filetransfererror/filetransfererror.md    |    1 +
 2 files changed, 45 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/24e3ba9c/docs/en/edge/cordova/file/filetransfer/filetransfer.md
----------------------------------------------------------------------
diff --git a/docs/en/edge/cordova/file/filetransfer/filetransfer.md b/docs/en/edge/cordova/file/filetransfer/filetransfer.md
index 001aa29..172da94 100644
--- a/docs/en/edge/cordova/file/filetransfer/filetransfer.md
+++ b/docs/en/edge/cordova/file/filetransfer/filetransfer.md
@@ -25,13 +25,14 @@ FileTransfer is an object that allows you to upload files to a server
or downloa
 Properties
 ----------
 
-N/A
+- __onprogress:__ Called with a ProgressEvent whenever a new chunk of data is transferred.
_(Function)_
 
 Methods
 -------
 
 - __upload__: sends a file to a server. 
 - __download__: downloads a file from server.
+- __abort__: Aborts an in-progress transfer.
 
 Details
 -------
@@ -60,7 +61,7 @@ __Parameters:__
 
 __Quick Example__
 	
-    // !! Assumes variable fileURI contains a valid URI to a  text file on the device
+    // !! Assumes variable fileURI contains a valid URI to a text file on the device
 	
   	var win = function(r) {
         console.log("Code = " + r.responseCode);
@@ -79,7 +80,7 @@ __Quick Example__
 	options.fileName=fileURI.substr(fileURI.lastIndexOf('/')+1);
 	options.mimeType="text/plain";
 
-    var params = new Object();
+  var params = {};
 	params.value1 = "test";
 	params.value2 = "param";
 		
@@ -122,7 +123,7 @@ __Full Example__
                 options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
                 options.mimeType="image/jpeg";
                 
-                var params = new Object();
+                var params = {};
                 params.value1 = "test";
                 params.value2 = "param";
                 
@@ -152,12 +153,9 @@ __Full Example__
     </body>
     </html>
     
-iOS Quirks
-----------
-
-Setting headers for FileTransfer Upload:
+__Setting Upload Headers__
 
-__Quick Example__
+Supported on Android and iOS
 
     function win(r) {
         console.log("Code = " + r.responseCode);
@@ -178,7 +176,7 @@ __Quick Example__
     options.fileName=fileURI.substr(fileURI.lastIndexOf('/')+1);
     options.mimeType="text/plain";
         
-    var params = new Object();
+    var params = {};
     params.headers={'headerParam':'headerValue'};
     
     options.params = params;
@@ -198,7 +196,7 @@ __Parameters:__
 
 __Quick Example__
 
-     // !! Assumes variable url contains a valid URI to a file on a server and filePath is
a valid path on the device
+    // !! Assumes filePath is a valid path on the device
 
     var fileTransfer = new FileTransfer();
     var uri = encodeURI("http://some.server.com/download.php");
@@ -214,4 +212,38 @@ __Quick Example__
             console.log("download error target " + error.target);
             console.log("upload error code" + error.code);
         }
-    );
\ No newline at end of file
+    );
+
+abort
+--------------
+
+Aborts an in-progress transfer. The onerror callback will be called with a FileTransferError
object which has an error code of FileTransferError.ABORT_ERR.
+
+__Supported Platforms__
+
+- Android
+- iOS
+
+onprogress
+--------------
+
+Called with a ProgressEvent whenever a new chunk of data is transferred.
+
+__Supported Platforms__
+
+- Android
+- iOS
+
+__Example__
+
+    fileTransfer.onprogress = function(progressEvent) {
+        if (progressEvent.lengthComputable) {
+          loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
+        } else {
+          loadingStatus.increment();
+        }
+    };
+    fileTransfer.download(...); // or fileTransfer.upload(...);
+
+__Quirks__
+- On both Android an iOS, lengthComputable is false for downloads that use gzip encoding.

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/24e3ba9c/docs/en/edge/cordova/file/filetransfererror/filetransfererror.md
----------------------------------------------------------------------
diff --git a/docs/en/edge/cordova/file/filetransfererror/filetransfererror.md b/docs/en/edge/cordova/file/filetransfererror/filetransfererror.md
index a643bf3..52e8eff 100644
--- a/docs/en/edge/cordova/file/filetransfererror/filetransfererror.md
+++ b/docs/en/edge/cordova/file/filetransfererror/filetransfererror.md
@@ -36,6 +36,7 @@ Constants
 - `FileTransferError.FILE_NOT_FOUND_ERR`
 - `FileTransferError.INVALID_URL_ERR`
 - `FileTransferError.CONNECTION_ERR`
+- `FileTransferError.ABORT_ERR`
 
 Description
 -----------


Mime
View raw message