incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [23/29] git commit: added documentation for download method of filetransfer and added source and target to the filetransfererror
Date Thu, 12 Jan 2012 20:14:00 GMT
added documentation for download method of filetransfer and added source and target to the
filetransfererror


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/c211a041
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/tree/c211a041
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/diff/c211a041

Branch: refs/heads/master
Commit: c211a04176d8b2354e30c7b418a530539c7e4775
Parents: b3826e4
Author: Alexander Heinrich <ak@aflx.de>
Authored: Sat Dec 3 17:44:24 2011 +0100
Committer: Fil Maj <filip.maj@nitobi.com>
Committed: Thu Jan 12 12:13:42 2012 -0800

----------------------------------------------------------------------
 .../phonegap/file/filetransfer/filetransfer.md     |   55 +++++++++++++--
 .../file/filetransfererror/filetransfererror.md    |    4 +-
 2 files changed, 52 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/c211a041/docs/en/edge/phonegap/file/filetransfer/filetransfer.md
----------------------------------------------------------------------
diff --git a/docs/en/edge/phonegap/file/filetransfer/filetransfer.md b/docs/en/edge/phonegap/file/filetransfer/filetransfer.md
index 154566a..3b57c90 100644
--- a/docs/en/edge/phonegap/file/filetransfer/filetransfer.md
+++ b/docs/en/edge/phonegap/file/filetransfer/filetransfer.md
@@ -1,7 +1,7 @@
 FileTransfer
 ==========
 
-FileTransfer is an object that allows you to upload files to a server.
+FileTransfer is an object that allows you to upload files to a server or download files from
a server.
 
 Properties
 ----------
@@ -12,11 +12,13 @@ Methods
 -------
 
 - __upload__: sends a file to a server. 
+- __download__: downloads a file from server.
 
 Details
 -------
 
 The `FileTransfer` object provides a way to upload files to a remote server using an HTTP
multi-part POST request.  Both HTTP and HTTPS protocols are supported.  Optional parameters
can be specified by passing a FileUploadOptions object to the upload method.  On successful
upload, the success callback will be called with a FileUploadResult object.  If an error occurs,
the error callback will be invoked with a FileTransferError object.
+It is also possible to download a file from remote and save it on the device (only iOS and
Android).
 
 Supported Platforms
 -------------------
@@ -26,10 +28,20 @@ Supported Platforms
 - iOS
 - Windows Phone 7 ( Mango )
 
-Quick Example
-------------------------------
+upload
+--------------
+
+__Parameters:__
+
+- __filePath__ - Full path of the file on the device
+- __server__ - URL of the server to receive the file
+- __successCallback__ - A callback that is called with a Metadata object. _(Function)_
+- __errorCallback__ - A callback that is called if an error occurs retrieving the Metadata.
Invoked with a FileError object. _(Function)_
+- __options__ - Optional parameters such as file name and mimetype
+
+__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);
@@ -39,6 +51,8 @@ Quick Example
 	
     var fail = function(error) {
         alert("An error has occurred: Code = " = error.code);
+        console.log("upload error source " + error.source);
+        console.log("upload error target " + error.target);
     }
 	
 	var options = new FileUploadOptions();
@@ -55,8 +69,7 @@ Quick Example
 	var ft = new FileTransfer();
     ft.upload(fileURI, "http://some.server.com/upload.php", win, fail, options);
     
-Full Example
-------------
+__Full Example__
 
     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
     <html>
@@ -108,6 +121,8 @@ Full Example
             
             function fail(error) {
                 alert("An error has occurred: Code = " = error.code);
+                console.log("upload error source " + error.source);
+                console.log("upload error target " + error.target);
             }
             
             </script>
@@ -118,3 +133,31 @@ Full Example
     </body>
     </html>
 
+download
+--------------
+
+__Parameters:__
+
+- __source__ - URL of the server to receive the file
+- __target__ - Full path of the file on the device
+- __successCallback__ - A callback that is called with a Metadata object. _(Function)_
+- __errorCallback__ - A callback that is called if an error occurs retrieving the Metadata.
Invoked with a FileError object. _(Function)_
+
+__Quick Example__
+
+     // !! Assumes variable url contains a valid URI to a file on a server and filePath is
a valid path on the device
+
+    var fileTransfer = new FileTransfer();
+    
+    fileTransfer.download(
+        url,
+        filePath,
+        function(entry) {
+            console.log("download complete: " + entry.fullPath);
+        },
+        function(error) {
+            console.log("download error source " + error.source);
+            console.log("download error target " + error.target);
+            console.log("upload error code" + error.code);
+        }
+    );

http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/c211a041/docs/en/edge/phonegap/file/filetransfererror/filetransfererror.md
----------------------------------------------------------------------
diff --git a/docs/en/edge/phonegap/file/filetransfererror/filetransfererror.md b/docs/en/edge/phonegap/file/filetransfererror/filetransfererror.md
index 6f81389..15f501f 100644
--- a/docs/en/edge/phonegap/file/filetransfererror/filetransfererror.md
+++ b/docs/en/edge/phonegap/file/filetransfererror/filetransfererror.md
@@ -6,7 +6,9 @@ A `FileTransferError` object is returned via the error callback when an error
oc
 Properties
 ----------
 
-- __code:__ One of the predefined error codes listed below. (int)
+- __code__ One of the predefined error codes listed below. (int)
+- __source__ URI to the source (string)
+- __target__ URI to the target (string)
 
 Constants
 ---------


Mime
View raw message