cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1766733 [11/18] - in /cordova/site/public: ./ announcements/2016/10/ announcements/2016/10/24/ blog/ docs/en/6.x/ docs/en/6.x/config_ref/ docs/en/6.x/cordova/events/ docs/en/6.x/cordova/storage/ docs/en/6.x/guide/appdev/hooks/ docs/en/6.x/...
Date Wed, 26 Oct 2016 20:28:36 GMT
Modified: cordova/site/public/docs/en/6.x/reference/cordova-plugin-file-transfer/index.html
URL: http://svn.apache.org/viewvc/cordova/site/public/docs/en/6.x/reference/cordova-plugin-file-transfer/index.html?rev=1766733&r1=1766732&r2=1766733&view=diff
==============================================================================
--- cordova/site/public/docs/en/6.x/reference/cordova-plugin-file-transfer/index.html (original)
+++ cordova/site/public/docs/en/6.x/reference/cordova-plugin-file-transfer/index.html Wed Oct 26 20:28:35 2016
@@ -6,12 +6,12 @@
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
     <meta name="format-detection" content="telephone=no">
     <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
-    <meta name="description" content=" ">
+    <meta name="description" content="Upload and download files. ">
 
     <title>
         
             
-                cordova-plugin-file-transfer - Apache Cordova
+                File Transfer - Apache Cordova
             
         
     </title>
@@ -747,7 +747,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-battery-status/index.html">
-                cordova-plugin-battery-status
+                Battery Status
             </a>
             
         
@@ -762,7 +762,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-camera/index.html">
-                cordova-plugin-camera
+                Camera
             </a>
             
         
@@ -777,7 +777,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-console/index.html">
-                cordova-plugin-console
+                Console
             </a>
             
         
@@ -792,7 +792,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-contacts/index.html">
-                cordova-plugin-contacts
+                Contacts
             </a>
             
         
@@ -807,7 +807,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-device/index.html">
-                cordova-plugin-device
+                Device
             </a>
             
         
@@ -822,7 +822,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-device-motion/index.html">
-                cordova-plugin-device-motion
+                Device Motion
             </a>
             
         
@@ -837,7 +837,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-device-orientation/index.html">
-                cordova-plugin-device-orientation
+                Device Orientation
             </a>
             
         
@@ -852,7 +852,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-dialogs/index.html">
-                cordova-plugin-dialogs
+                Dialogs
             </a>
             
         
@@ -867,7 +867,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-file/index.html">
-                cordova-plugin-file
+                File
             </a>
             
         
@@ -882,7 +882,7 @@
     <li>
         
             <a class="this-page" href="../../reference/cordova-plugin-file-transfer/index.html">
-                cordova-plugin-file-transfer
+                File Transfer
             </a>
             
                 <span class="entry-highlight"></span>
@@ -899,7 +899,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-geolocation/index.html">
-                cordova-plugin-geolocation
+                Geolocation
             </a>
             
         
@@ -914,7 +914,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-globalization/index.html">
-                cordova-plugin-globalization
+                Globalization
             </a>
             
         
@@ -929,7 +929,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-inappbrowser/index.html">
-                cordova-plugin-inappbrowser
+                Inappbrowser
             </a>
             
         
@@ -944,7 +944,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-media/index.html">
-                cordova-plugin-media
+                Media
             </a>
             
         
@@ -959,7 +959,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-media-capture/index.html">
-                cordova-plugin-media-capture
+                Media Capture
             </a>
             
         
@@ -974,7 +974,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-network-information/index.html">
-                cordova-plugin-network-information
+                Network Information
             </a>
             
         
@@ -989,7 +989,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-splashscreen/index.html">
-                cordova-plugin-splashscreen
+                Splashscreen
             </a>
             
         
@@ -1004,7 +1004,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-vibration/index.html">
-                cordova-plugin-vibration
+                Vibration
             </a>
             
         
@@ -1019,7 +1019,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-statusbar/index.html">
-                cordova-plugin-statusbar
+                Statusbar
             </a>
             
         
@@ -1034,7 +1034,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-whitelist/index.html">
-                cordova-plugin-whitelist
+                Whitelist
             </a>
             
         
@@ -1049,7 +1049,7 @@
     <li>
         
             <a class="" href="../../reference/cordova-plugin-legacy-whitelist/index.html">
-                cordova-plugin-legacy-whitelist
+                Legacy Whitelist
             </a>
             
         
@@ -1412,7 +1412,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-battery-status/index.html">
-        cordova-plugin-battery-status
+        Battery Status
     </a>
 </li>
 
@@ -1421,7 +1421,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-camera/index.html">
-        cordova-plugin-camera
+        Camera
     </a>
 </li>
 
@@ -1430,7 +1430,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-console/index.html">
-        cordova-plugin-console
+        Console
     </a>
 </li>
 
@@ -1439,7 +1439,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-contacts/index.html">
-        cordova-plugin-contacts
+        Contacts
     </a>
 </li>
 
@@ -1448,7 +1448,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-device/index.html">
-        cordova-plugin-device
+        Device
     </a>
 </li>
 
@@ -1457,7 +1457,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-device-motion/index.html">
-        cordova-plugin-device-motion
+        Device Motion
     </a>
 </li>
 
@@ -1466,7 +1466,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-device-orientation/index.html">
-        cordova-plugin-device-orientation
+        Device Orientation
     </a>
 </li>
 
@@ -1475,7 +1475,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-dialogs/index.html">
-        cordova-plugin-dialogs
+        Dialogs
     </a>
 </li>
 
@@ -1484,7 +1484,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-file/index.html">
-        cordova-plugin-file
+        File
     </a>
 </li>
 
@@ -1493,7 +1493,7 @@
 
 <li>
     <a class="this-page" href="../../reference/cordova-plugin-file-transfer/index.html">
-        cordova-plugin-file-transfer
+        File Transfer
     </a>
 </li>
 
@@ -1502,7 +1502,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-geolocation/index.html">
-        cordova-plugin-geolocation
+        Geolocation
     </a>
 </li>
 
@@ -1511,7 +1511,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-globalization/index.html">
-        cordova-plugin-globalization
+        Globalization
     </a>
 </li>
 
@@ -1520,7 +1520,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-inappbrowser/index.html">
-        cordova-plugin-inappbrowser
+        Inappbrowser
     </a>
 </li>
 
@@ -1529,7 +1529,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-media/index.html">
-        cordova-plugin-media
+        Media
     </a>
 </li>
 
@@ -1538,7 +1538,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-media-capture/index.html">
-        cordova-plugin-media-capture
+        Media Capture
     </a>
 </li>
 
@@ -1547,7 +1547,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-network-information/index.html">
-        cordova-plugin-network-information
+        Network Information
     </a>
 </li>
 
@@ -1556,7 +1556,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-splashscreen/index.html">
-        cordova-plugin-splashscreen
+        Splashscreen
     </a>
 </li>
 
@@ -1565,7 +1565,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-vibration/index.html">
-        cordova-plugin-vibration
+        Vibration
     </a>
 </li>
 
@@ -1574,7 +1574,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-statusbar/index.html">
-        cordova-plugin-statusbar
+        Statusbar
     </a>
 </li>
 
@@ -1583,7 +1583,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-whitelist/index.html">
-        cordova-plugin-whitelist
+        Whitelist
     </a>
 </li>
 
@@ -1592,7 +1592,7 @@
 
 <li>
     <a class="" href="../../reference/cordova-plugin-legacy-whitelist/index.html">
-        cordova-plugin-legacy-whitelist
+        Legacy Whitelist
     </a>
 </li>
 
@@ -2704,22 +2704,46 @@
 #         under the License.
 -->
 
-<p><a href="https://travis-ci.org/apache/cordova-plugin-file-transfer"><img src="https://travis-ci.org/apache/cordova-plugin-file-transfer.svg?branch=master" alt="Build Status"></a></p>
+<table><thead>
+<tr>
+<th style="text-align: center">Android</th>
+<th style="text-align: center">iOS</th>
+<th style="text-align: center">Windows 8.1 Store</th>
+<th style="text-align: center">Windows 8.1 Phone</th>
+<th style="text-align: center">Windows 10 Store</th>
+<th style="text-align: center">Travis CI</th>
+</tr>
+</thead><tbody>
+<tr>
+<td style="text-align: center"><a href="http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-file-transfer/"><img src="http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-file-transfer" alt="Build Status"></a></td>
+<td style="text-align: center"><a href="http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-file-transfer/"><img src="http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-file-transfer" alt="Build Status"></a></td>
+<td style="text-align: center"><a href="http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-file-transfer/"><img src="http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-file-transfer" alt="Build Status"></a></td>
+<td style="text-align: center"><a href="http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-file-transfer/"><img src="http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-file-transfer" alt="Build Status"></a></td>
+<td style="text-align: center"><a href="http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-file-transfer/"><img src="http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-file-transfer" alt="Build Status"></a></td>
+<td style="text-align: center"><a href="https://travis-ci.org/apache/cordova-plugin-file-transfer"><img src="https://travis-ci.org/apache/cordova-plugin-file-transfer.svg?branch=master" alt="Build Status"></a></td>
+</tr>
+</tbody></table>
 
 <h1>cordova-plugin-file-transfer</h1>
 
 <p>This plugin allows you to upload and download files.</p>
 
 <p>This plugin defines global <code>FileTransfer</code>, <code>FileUploadOptions</code> constructors. Although in the global scope, they are not available until after the <code>deviceready</code> event.</p>
-<div class="highlight"><pre><code class="language-" data-lang="">document.addEventListener("deviceready", onDeviceReady, false);
-function onDeviceReady() {
-    console.log(FileTransfer);
-}
+<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="nb">document</span><span class="p">.</span><span class="nx">addEventListener</span><span class="p">(</span><span class="s2">"deviceready"</span><span class="p">,</span> <span class="nx">onDeviceReady</span><span class="p">,</span> <span class="kc">false</span><span class="p">);</span>
+<span class="kd">function</span> <span class="nx">onDeviceReady</span><span class="p">()</span> <span class="p">{</span>
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">FileTransfer</span><span class="p">);</span>
+<span class="p">}</span>
 </code></pre></div>
+<blockquote>
+<p>To get a few ideas, check out the <a href="#sample">sample</a> at the bottom of this page or go straight to the <a href="#reference">reference</a> content.</p>
+</blockquote>
+
 <p>Report issues with this plugin on the <a href="https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20File%20Transfer%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC">Apache Cordova issue tracker</a></p>
 
+<h2><a name="reference"></a>Reference</h2>
+
 <h2>Installation</h2>
-<div class="highlight"><pre><code class="language-" data-lang="">cordova plugin add cordova-plugin-file-transfer
+<div class="highlight"><pre><code class="language-bash" data-lang="bash">cordova plugin add cordova-plugin-file-transfer
 </code></pre></div>
 <h2>Supported Platforms</h2>
 
@@ -2781,68 +2805,68 @@ multi-part POST or PUT request, and to d
 </ul>
 
 <h3>Example</h3>
-<div class="highlight"><pre><code class="language-" data-lang="">// !! Assumes variable fileURL contains a valid URL to a text file on the device,
-//    for example, cdvfile://localhost/persistent/path/to/file.txt
+<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="c1">// !! Assumes variable fileURL contains a valid URL to a text file on the device,</span>
+<span class="c1">//    for example, cdvfile://localhost/persistent/path/to/file.txt</span>
 
-var win = function (r) {
-    console.log("Code = " + r.responseCode);
-    console.log("Response = " + r.response);
-    console.log("Sent = " + r.bytesSent);
-}
-
-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();
-options.fileKey = "file";
-options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
-options.mimeType = "text/plain";
-
-var params = {};
-params.value1 = "test";
-params.value2 = "param";
+<span class="kd">var</span> <span class="nx">win</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">r</span><span class="p">)</span> <span class="p">{</span>
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"Code = "</span> <span class="o">+</span> <span class="nx">r</span><span class="p">.</span><span class="nx">responseCode</span><span class="p">);</span>
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"Response = "</span> <span class="o">+</span> <span class="nx">r</span><span class="p">.</span><span class="nx">response</span><span class="p">);</span>
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"Sent = "</span> <span class="o">+</span> <span class="nx">r</span><span class="p">.</span><span class="nx">bytesSent</span><span class="p">);</span>
+<span class="p">}</span>
+
+<span class="kd">var</span> <span class="nx">fail</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
+    <span class="nx">alert</span><span class="p">(</span><span class="s2">"An error has occurred: Code = "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">code</span><span class="p">);</span>
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"upload error source "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">source</span><span class="p">);</span>
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"upload error target "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">target</span><span class="p">);</span>
+<span class="p">}</span>
+
+<span class="kd">var</span> <span class="nx">options</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">FileUploadOptions</span><span class="p">();</span>
+<span class="nx">options</span><span class="p">.</span><span class="nx">fileKey</span> <span class="o">=</span> <span class="s2">"file"</span><span class="p">;</span>
+<span class="nx">options</span><span class="p">.</span><span class="nx">fileName</span> <span class="o">=</span> <span class="nx">fileURL</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="nx">fileURL</span><span class="p">.</span><span class="nx">lastIndexOf</span><span class="p">(</span><span class="s1">'/'</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">);</span>
+<span class="nx">options</span><span class="p">.</span><span class="nx">mimeType</span> <span class="o">=</span> <span class="s2">"text/plain"</span><span class="p">;</span>
+
+<span class="kd">var</span> <span class="nx">params</span> <span class="o">=</span> <span class="p">{};</span>
+<span class="nx">params</span><span class="p">.</span><span class="nx">value1</span> <span class="o">=</span> <span class="s2">"test"</span><span class="p">;</span>
+<span class="nx">params</span><span class="p">.</span><span class="nx">value2</span> <span class="o">=</span> <span class="s2">"param"</span><span class="p">;</span>
 
-options.params = params;
+<span class="nx">options</span><span class="p">.</span><span class="nx">params</span> <span class="o">=</span> <span class="nx">params</span><span class="p">;</span>
 
-var ft = new FileTransfer();
-ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
+<span class="kd">var</span> <span class="nx">ft</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">FileTransfer</span><span class="p">();</span>
+<span class="nx">ft</span><span class="p">.</span><span class="nx">upload</span><span class="p">(</span><span class="nx">fileURL</span><span class="p">,</span> <span class="nb">encodeURI</span><span class="p">(</span><span class="s2">"http://some.server.com/upload.php"</span><span class="p">),</span> <span class="nx">win</span><span class="p">,</span> <span class="nx">fail</span><span class="p">,</span> <span class="nx">options</span><span class="p">);</span>
 </code></pre></div>
 <h3>Example with Upload Headers and Progress Events (Android and iOS only)</h3>
-<div class="highlight"><pre><code class="language-" data-lang="">function win(r) {
-    console.log("Code = " + r.responseCode);
-    console.log("Response = " + r.response);
-    console.log("Sent = " + r.bytesSent);
-}
-
-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);
-}
-
-var uri = encodeURI("http://some.server.com/upload.php");
-
-var options = new FileUploadOptions();
-options.fileKey="file";
-options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
-options.mimeType="text/plain";
-
-var headers={'headerParam':'headerValue'};
-
-options.headers = headers;
-
-var ft = new FileTransfer();
-ft.onprogress = function(progressEvent) {
-    if (progressEvent.lengthComputable) {
-      loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
-    } else {
-      loadingStatus.increment();
-    }
-};
-ft.upload(fileURL, uri, win, fail, options);
+<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kd">function</span> <span class="nx">win</span><span class="p">(</span><span class="nx">r</span><span class="p">)</span> <span class="p">{</span>
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"Code = "</span> <span class="o">+</span> <span class="nx">r</span><span class="p">.</span><span class="nx">responseCode</span><span class="p">);</span>
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"Response = "</span> <span class="o">+</span> <span class="nx">r</span><span class="p">.</span><span class="nx">response</span><span class="p">);</span>
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"Sent = "</span> <span class="o">+</span> <span class="nx">r</span><span class="p">.</span><span class="nx">bytesSent</span><span class="p">);</span>
+<span class="p">}</span>
+
+<span class="kd">function</span> <span class="nx">fail</span><span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
+    <span class="nx">alert</span><span class="p">(</span><span class="s2">"An error has occurred: Code = "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">code</span><span class="p">);</span>
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"upload error source "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">source</span><span class="p">);</span>
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"upload error target "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">target</span><span class="p">);</span>
+<span class="p">}</span>
+
+<span class="kd">var</span> <span class="nx">uri</span> <span class="o">=</span> <span class="nb">encodeURI</span><span class="p">(</span><span class="s2">"http://some.server.com/upload.php"</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">options</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">FileUploadOptions</span><span class="p">();</span>
+<span class="nx">options</span><span class="p">.</span><span class="nx">fileKey</span><span class="o">=</span><span class="s2">"file"</span><span class="p">;</span>
+<span class="nx">options</span><span class="p">.</span><span class="nx">fileName</span><span class="o">=</span><span class="nx">fileURL</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="nx">fileURL</span><span class="p">.</span><span class="nx">lastIndexOf</span><span class="p">(</span><span class="s1">'/'</span><span class="p">)</span><span class="o">+</span><span class="mi">1</span><span class="p">);</span>
+<span class="nx">options</span><span class="p">.</span><span class="nx">mimeType</span><span class="o">=</span><span class="s2">"text/plain"</span><span class="p">;</span>
+
+<span class="kd">var</span> <span class="nx">headers</span><span class="o">=</span><span class="p">{</span><span class="s1">'headerParam'</span><span class="p">:</span><span class="s1">'headerValue'</span><span class="p">};</span>
+
+<span class="nx">options</span><span class="p">.</span><span class="nx">headers</span> <span class="o">=</span> <span class="nx">headers</span><span class="p">;</span>
+
+<span class="kd">var</span> <span class="nx">ft</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">FileTransfer</span><span class="p">();</span>
+<span class="nx">ft</span><span class="p">.</span><span class="nx">onprogress</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">progressEvent</span><span class="p">)</span> <span class="p">{</span>
+    <span class="k">if</span> <span class="p">(</span><span class="nx">progressEvent</span><span class="p">.</span><span class="nx">lengthComputable</span><span class="p">)</span> <span class="p">{</span>
+        <span class="nx">loadingStatus</span><span class="p">.</span><span class="nx">setPercentage</span><span class="p">(</span><span class="nx">progressEvent</span><span class="p">.</span><span class="nx">loaded</span> <span class="o">/</span> <span class="nx">progressEvent</span><span class="p">.</span><span class="nx">total</span><span class="p">);</span>
+    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
+        <span class="nx">loadingStatus</span><span class="p">.</span><span class="nx">increment</span><span class="p">();</span>
+    <span class="p">}</span>
+<span class="p">};</span>
+<span class="nx">ft</span><span class="p">.</span><span class="nx">upload</span><span class="p">(</span><span class="nx">fileURL</span><span class="p">,</span> <span class="nx">uri</span><span class="p">,</span> <span class="nx">win</span><span class="p">,</span> <span class="nx">fail</span><span class="p">,</span> <span class="nx">options</span><span class="p">);</span>
 </code></pre></div>
 <h2>FileUploadResult</h2>
 
@@ -2865,7 +2889,8 @@ ft.upload(fileURL, uri, win, fail, optio
 <h3>iOS Quirks</h3>
 
 <ul>
-<li>Does not support <code>responseCode</code> or <code>bytesSent</code>.</li>
+<li><p>Does not support <code>responseCode</code> or <code>bytesSent</code>.</p></li>
+<li><p>Does not support uploads of an empty file with <strong>chunkedMode=true</strong> and <code>multipartMode=false</code>.</p></li>
 </ul>
 
 <h3>Browser Quirks</h3>
@@ -2874,6 +2899,13 @@ ft.upload(fileURL, uri, win, fail, optio
 <li><strong>withCredentials</strong>: <em>boolean</em> that tells the browser to set the withCredentials flag on the XMLHttpRequest</li>
 </ul>
 
+<h3>Windows Quirks</h3>
+
+<ul>
+<li><p>An option parameter with empty/null value is excluded in the upload operation due to the Windows API design.</p></li>
+<li><p><strong>chunkedMode</strong> is not supported and all uploads are set to non-chunked mode.</p></li>
+</ul>
+
 <h2>download</h2>
 
 <p><strong>Parameters</strong>:</p>
@@ -2888,30 +2920,30 @@ ft.upload(fileURL, uri, win, fail, optio
 </ul>
 
 <h3>Example</h3>
-<div class="highlight"><pre><code class="language-" data-lang="">// !! Assumes variable fileURL contains a valid URL to a path on the device,
-//    for example, cdvfile://localhost/persistent/path/to/downloads/
+<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="c1">// !! Assumes variable fileURL contains a valid URL to a path on the device,</span>
+<span class="c1">//    for example, cdvfile://localhost/persistent/path/to/downloads/</span>
 
-var fileTransfer = new FileTransfer();
-var uri = encodeURI("http://some.server.com/download.php");
+<span class="kd">var</span> <span class="nx">fileTransfer</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">FileTransfer</span><span class="p">();</span>
+<span class="kd">var</span> <span class="nx">uri</span> <span class="o">=</span> <span class="nb">encodeURI</span><span class="p">(</span><span class="s2">"http://some.server.com/download.php"</span><span class="p">);</span>
 
-fileTransfer.download(
-    uri,
-    fileURL,
-    function(entry) {
-        console.log("download complete: " + entry.toURL());
-    },
-    function(error) {
-        console.log("download error source " + error.source);
-        console.log("download error target " + error.target);
-        console.log("upload error code" + error.code);
-    },
-    false,
-    {
-        headers: {
-            "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
-        }
-    }
-);
+<span class="nx">fileTransfer</span><span class="p">.</span><span class="nx">download</span><span class="p">(</span>
+    <span class="nx">uri</span><span class="p">,</span>
+    <span class="nx">fileURL</span><span class="p">,</span>
+    <span class="kd">function</span><span class="p">(</span><span class="nx">entry</span><span class="p">)</span> <span class="p">{</span>
+        <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"download complete: "</span> <span class="o">+</span> <span class="nx">entry</span><span class="p">.</span><span class="nx">toURL</span><span class="p">());</span>
+    <span class="p">},</span>
+    <span class="kd">function</span><span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
+        <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"download error source "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">source</span><span class="p">);</span>
+        <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"download error target "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">target</span><span class="p">);</span>
+        <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"download error code"</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">code</span><span class="p">);</span>
+    <span class="p">},</span>
+    <span class="kc">false</span><span class="p">,</span>
+    <span class="p">{</span>
+        <span class="na">headers</span><span class="p">:</span> <span class="p">{</span>
+            <span class="s2">"Authorization"</span><span class="p">:</span> <span class="s2">"Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="</span>
+        <span class="p">}</span>
+    <span class="p">}</span>
+<span class="p">);</span>
 </code></pre></div>
 <h3>WP8 Quirks</h3>
 
@@ -2930,28 +2962,28 @@ fileTransfer.download(
 <p>Aborts an in-progress transfer. The onerror callback is passed a FileTransferError object which has an error code of <code>FileTransferError.ABORT_ERR</code>.</p>
 
 <h3>Example</h3>
-<div class="highlight"><pre><code class="language-" data-lang="">// !! Assumes variable fileURL contains a valid URL to a text file on the device,
-//    for example, cdvfile://localhost/persistent/path/to/file.txt
+<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="c1">// !! Assumes variable fileURL contains a valid URL to a text file on the device,</span>
+<span class="c1">//    for example, cdvfile://localhost/persistent/path/to/file.txt</span>
 
-var win = function(r) {
-    console.log("Should not be called.");
-}
-
-var fail = function(error) {
-    // error.code == FileTransferError.ABORT_ERR
-    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();
-options.fileKey="file";
-options.fileName="myphoto.jpg";
-options.mimeType="image/jpeg";
-
-var ft = new FileTransfer();
-ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);
-ft.abort();
+<span class="kd">var</span> <span class="nx">win</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">r</span><span class="p">)</span> <span class="p">{</span>
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"Should not be called."</span><span class="p">);</span>
+<span class="p">}</span>
+
+<span class="kd">var</span> <span class="nx">fail</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
+    <span class="c1">// error.code == FileTransferError.ABORT_ERR</span>
+    <span class="nx">alert</span><span class="p">(</span><span class="s2">"An error has occurred: Code = "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">code</span><span class="p">);</span>
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"upload error source "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">source</span><span class="p">);</span>
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"upload error target "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">target</span><span class="p">);</span>
+<span class="p">}</span>
+
+<span class="kd">var</span> <span class="nx">options</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">FileUploadOptions</span><span class="p">();</span>
+<span class="nx">options</span><span class="p">.</span><span class="nx">fileKey</span><span class="o">=</span><span class="s2">"file"</span><span class="p">;</span>
+<span class="nx">options</span><span class="p">.</span><span class="nx">fileName</span><span class="o">=</span><span class="s2">"myphoto.jpg"</span><span class="p">;</span>
+<span class="nx">options</span><span class="p">.</span><span class="nx">mimeType</span><span class="o">=</span><span class="s2">"image/jpeg"</span><span class="p">;</span>
+
+<span class="kd">var</span> <span class="nx">ft</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">FileTransfer</span><span class="p">();</span>
+<span class="nx">ft</span><span class="p">.</span><span class="nx">upload</span><span class="p">(</span><span class="nx">fileURL</span><span class="p">,</span> <span class="nb">encodeURI</span><span class="p">(</span><span class="s2">"http://some.server.com/upload.php"</span><span class="p">),</span> <span class="nx">win</span><span class="p">,</span> <span class="nx">fail</span><span class="p">,</span> <span class="nx">options</span><span class="p">);</span>
+<span class="nx">ft</span><span class="p">.</span><span class="nx">abort</span><span class="p">();</span>
 </code></pre></div>
 <h2>FileTransferError</h2>
 
@@ -3001,6 +3033,230 @@ ft.abort();
 </code></pre></div>
 <p>which can be used in place of the absolute file path in both <code>download()</code> and <code>upload()</code> methods.</p>
 
+<h2>Sample: Download and Upload Files <a name="sample"></a></h2>
+
+<p>Use the File-Transfer plugin to upload and download files. In these examples, we demonstrate several tasks like:</p>
+
+<ul>
+<li><a href="#binaryFile">Downloading a binary file to the application cache</a></li>
+<li><a href="#uploadFile">Uploading a file created in your application&#39;s root</a></li>
+<li><a href="#downloadFile">Downloading the uploaded file</a></li>
+</ul>
+
+<h2>Download a Binary File to the application cache <a name="binaryFile"></a></h2>
+
+<p>Use the File plugin with the File-Transfer plugin to provide a target for the files that you download (the target must be a FileEntry object). Before you download the file, create a DirectoryEntry object by using <code>resolveLocalFileSystemURL</code> and calling <code>fs.root</code> in the success callback. Use the <code>getFile</code> method of DirectoryEntry to create the target file.</p>
+<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="nb">window</span><span class="p">.</span><span class="nx">requestFileSystem</span><span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">TEMPORARY</span><span class="p">,</span> <span class="mi">5</span> <span class="o">*</span> <span class="mi">1024</span> <span class="o">*</span> <span class="mi">1024</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">fs</span><span class="p">)</span> <span class="p">{</span>
+
+    <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">'file system open: '</span> <span class="o">+</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">name</span><span class="p">);</span>
+
+    <span class="c1">// Make sure you add the domain name to the Content-Security-Policy &lt;meta&gt; element.</span>
+    <span class="kd">var</span> <span class="nx">url</span> <span class="o">=</span> <span class="s1">'http://cordova.apache.org/static/img/cordova_bot.png'</span><span class="p">;</span>
+    <span class="c1">// Parameters passed to getFile create a new file or return the file if it already exists.</span>
+    <span class="nx">fs</span><span class="p">.</span><span class="nx">root</span><span class="p">.</span><span class="nx">getFile</span><span class="p">(</span><span class="s1">'downloaded-image.png'</span><span class="p">,</span> <span class="p">{</span> <span class="na">create</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span> <span class="na">exclusive</span><span class="p">:</span> <span class="kc">false</span> <span class="p">},</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">fileEntry</span><span class="p">)</span> <span class="p">{</span>
+        <span class="nx">download</span><span class="p">(</span><span class="nx">fileEntry</span><span class="p">,</span> <span class="nx">url</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
+
+    <span class="p">},</span> <span class="nx">onErrorCreateFile</span><span class="p">);</span>
+
+<span class="p">},</span> <span class="nx">onErrorLoadFs</span><span class="p">);</span>
+</code></pre></div>
+<blockquote>
+<p><em>Note</em> For persistent storage, pass LocalFileSystem.PERSISTENT to requestFileSystem.</p>
+</blockquote>
+
+<p>When you have the FileEntry object, download the file using the <code>download</code> method of the FileTransfer object. The 3rd argument to the <code>download</code> function of FileTransfer is the success callback, which you can use to call the app&#39;s <code>readBinaryFile</code> function. In this code example, the <code>entry</code> variable is a new FileEntry object that receives the result of the download operation.</p>
+<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kd">function</span> <span class="nx">download</span><span class="p">(</span><span class="nx">fileEntry</span><span class="p">,</span> <span class="nx">uri</span><span class="p">,</span> <span class="nx">readBinaryData</span><span class="p">)</span> <span class="p">{</span>
+
+    <span class="kd">var</span> <span class="nx">fileTransfer</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">FileTransfer</span><span class="p">();</span>
+    <span class="kd">var</span> <span class="nx">fileURL</span> <span class="o">=</span> <span class="nx">fileEntry</span><span class="p">.</span><span class="nx">toURL</span><span class="p">();</span>
+
+    <span class="nx">fileTransfer</span><span class="p">.</span><span class="nx">download</span><span class="p">(</span>
+        <span class="nx">uri</span><span class="p">,</span>
+        <span class="nx">fileURL</span><span class="p">,</span>
+        <span class="kd">function</span> <span class="p">(</span><span class="nx">entry</span><span class="p">)</span> <span class="p">{</span>
+            <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"Successful download..."</span><span class="p">);</span>
+            <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"download complete: "</span> <span class="o">+</span> <span class="nx">entry</span><span class="p">.</span><span class="nx">toURL</span><span class="p">());</span>
+            <span class="k">if</span> <span class="p">(</span><span class="nx">readBinaryData</span><span class="p">)</span> <span class="p">{</span>
+              <span class="c1">// Read the file...</span>
+              <span class="nx">readBinaryFile</span><span class="p">(</span><span class="nx">entry</span><span class="p">);</span>
+            <span class="p">}</span>
+            <span class="k">else</span> <span class="p">{</span>
+              <span class="c1">// Or just display it.</span>
+              <span class="nx">displayImageByFileURL</span><span class="p">(</span><span class="nx">entry</span><span class="p">);</span>
+            <span class="p">}</span>
+        <span class="p">},</span>
+        <span class="kd">function</span> <span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
+            <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"download error source "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">source</span><span class="p">);</span>
+            <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"download error target "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">target</span><span class="p">);</span>
+            <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"upload error code"</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">code</span><span class="p">);</span>
+        <span class="p">},</span>
+        <span class="kc">null</span><span class="p">,</span> <span class="c1">// or, pass false</span>
+        <span class="p">{</span>
+            <span class="c1">//headers: {</span>
+            <span class="c1">//    "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="</span>
+            <span class="c1">//}</span>
+        <span class="p">}</span>
+    <span class="p">);</span>
+<span class="p">}</span>
+</code></pre></div>
+<p>If you just need to display the image, take the FileEntry to call its toURL() function.</p>
+<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kd">function</span> <span class="nx">displayImageByFileURL</span><span class="p">(</span><span class="nx">fileEntry</span><span class="p">)</span> <span class="p">{</span>
+    <span class="kd">var</span> <span class="nx">elem</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'imageElement'</span><span class="p">);</span>
+    <span class="nx">elem</span><span class="p">.</span><span class="nx">src</span> <span class="o">=</span> <span class="nx">fileEntry</span><span class="p">.</span><span class="nx">toURL</span><span class="p">();</span>
+<span class="p">}</span>
+</code></pre></div>
+<p>Depending on your app requirements, you may want to read the file. To support operations with binary files, FileReader supports two methods, <code>readAsBinaryString</code> and <code>readAsArrayBuffer</code>. In this example, use <code>readAsArrayBuffer</code> and pass the FileEntry object to the method. Once you read the file successfully, construct a Blob object using the result of the read.</p>
+<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kd">function</span> <span class="nx">readBinaryFile</span><span class="p">(</span><span class="nx">fileEntry</span><span class="p">)</span> <span class="p">{</span>
+    <span class="nx">fileEntry</span><span class="p">.</span><span class="nx">file</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">file</span><span class="p">)</span> <span class="p">{</span>
+        <span class="kd">var</span> <span class="nx">reader</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">FileReader</span><span class="p">();</span>
+
+        <span class="nx">reader</span><span class="p">.</span><span class="nx">onloadend</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
+
+            <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"Successful file read: "</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">result</span><span class="p">);</span>
+            <span class="c1">// displayFileData(fileEntry.fullPath + ": " + this.result);</span>
+
+            <span class="kd">var</span> <span class="nx">blob</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Blob</span><span class="p">([</span><span class="k">new</span> <span class="nx">Uint8Array</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">result</span><span class="p">)],</span> <span class="p">{</span> <span class="na">type</span><span class="p">:</span> <span class="s2">"image/png"</span> <span class="p">});</span>
+            <span class="nx">displayImage</span><span class="p">(</span><span class="nx">blob</span><span class="p">);</span>
+        <span class="p">};</span>
+
+        <span class="nx">reader</span><span class="p">.</span><span class="nx">readAsArrayBuffer</span><span class="p">(</span><span class="nx">file</span><span class="p">);</span>
+
+    <span class="p">},</span> <span class="nx">onErrorReadFile</span><span class="p">);</span>
+<span class="p">}</span>
+</code></pre></div>
+<p>Once you read the file successfully, you can create a DOM URL string using <code>createObjectURL</code>, and then display the image.</p>
+<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kd">function</span> <span class="nx">displayImage</span><span class="p">(</span><span class="nx">blob</span><span class="p">)</span> <span class="p">{</span>
+
+    <span class="c1">// Note: Use window.URL.revokeObjectURL when finished with image.</span>
+    <span class="kd">var</span> <span class="nx">objURL</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">URL</span><span class="p">.</span><span class="nx">createObjectURL</span><span class="p">(</span><span class="nx">blob</span><span class="p">);</span>
+
+    <span class="c1">// Displays image if result is a valid DOM string for an image.</span>
+    <span class="kd">var</span> <span class="nx">elem</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'imageElement'</span><span class="p">);</span>
+    <span class="nx">elem</span><span class="p">.</span><span class="nx">src</span> <span class="o">=</span> <span class="nx">objURL</span><span class="p">;</span>
+<span class="p">}</span>
+</code></pre></div>
+<p>As you saw previously, you can call FileEntry.toURL() instead to just display the downloaded image (skip the file read).</p>
+
+<h2>Upload a File <a name="uploadFile"></a></h2>
+
+<p>When you upload a File using the File-Transfer plugin, use the File plugin to provide files for upload (again, they must be FileEntry objects). Before you can upload anything, create a file for upload using the <code>getFile</code> method of DirectoryEntry. In this example, create the file in the application&#39;s cache (fs.root). Then call the app&#39;s writeFile function so you have some content to upload.</p>
+<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kd">function</span> <span class="nx">onUploadFile</span><span class="p">()</span> <span class="p">{</span>
+    <span class="nb">window</span><span class="p">.</span><span class="nx">requestFileSystem</span><span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">TEMPORARY</span><span class="p">,</span> <span class="mi">5</span> <span class="o">*</span> <span class="mi">1024</span> <span class="o">*</span> <span class="mi">1024</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">fs</span><span class="p">)</span> <span class="p">{</span>
+
+        <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">'file system open: '</span> <span class="o">+</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">name</span><span class="p">);</span>
+        <span class="kd">var</span> <span class="nx">fileName</span> <span class="o">=</span> <span class="s2">"uploadSource.txt"</span><span class="p">;</span>
+        <span class="kd">var</span> <span class="nx">dirEntry</span> <span class="o">=</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">root</span><span class="p">;</span>
+        <span class="nx">dirEntry</span><span class="p">.</span><span class="nx">getFile</span><span class="p">(</span><span class="nx">fileName</span><span class="p">,</span> <span class="p">{</span> <span class="na">create</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span> <span class="na">exclusive</span><span class="p">:</span> <span class="kc">false</span> <span class="p">},</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">fileEntry</span><span class="p">)</span> <span class="p">{</span>
+
+            <span class="c1">// Write something to the file before uploading it.</span>
+            <span class="nx">writeFile</span><span class="p">(</span><span class="nx">fileEntry</span><span class="p">);</span>
+
+        <span class="p">},</span> <span class="nx">onErrorCreateFile</span><span class="p">);</span>
+
+    <span class="p">},</span> <span class="nx">onErrorLoadFs</span><span class="p">);</span>
+<span class="p">}</span>
+</code></pre></div>
+<p>In this example, create some simple content, and then call the app&#39;s upload function.</p>
+<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kd">function</span> <span class="nx">writeFile</span><span class="p">(</span><span class="nx">fileEntry</span><span class="p">,</span> <span class="nx">dataObj</span><span class="p">)</span> <span class="p">{</span>
+    <span class="c1">// Create a FileWriter object for our FileEntry (log.txt).</span>
+    <span class="nx">fileEntry</span><span class="p">.</span><span class="nx">createWriter</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">fileWriter</span><span class="p">)</span> <span class="p">{</span>
+
+        <span class="nx">fileWriter</span><span class="p">.</span><span class="nx">onwriteend</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+            <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"Successful file write..."</span><span class="p">);</span>
+            <span class="nx">upload</span><span class="p">(</span><span class="nx">fileEntry</span><span class="p">);</span>
+        <span class="p">};</span>
+
+        <span class="nx">fileWriter</span><span class="p">.</span><span class="nx">onerror</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
+            <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"Failed file write: "</span> <span class="o">+</span> <span class="nx">e</span><span class="p">.</span><span class="nx">toString</span><span class="p">());</span>
+        <span class="p">};</span>
+
+        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">dataObj</span><span class="p">)</span> <span class="p">{</span>
+          <span class="nx">dataObj</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Blob</span><span class="p">([</span><span class="s1">'file data to upload'</span><span class="p">],</span> <span class="p">{</span> <span class="na">type</span><span class="p">:</span> <span class="s1">'text/plain'</span> <span class="p">});</span>
+        <span class="p">}</span>
+
+        <span class="nx">fileWriter</span><span class="p">.</span><span class="nx">write</span><span class="p">(</span><span class="nx">dataObj</span><span class="p">);</span>
+    <span class="p">});</span>
+<span class="p">}</span>
+</code></pre></div>
+<p>Forward the FileEntry object to the upload function. To perform the actual upload, use the upload function of the FileTransfer object.</p>
+<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kd">function</span> <span class="nx">upload</span><span class="p">(</span><span class="nx">fileEntry</span><span class="p">)</span> <span class="p">{</span>
+    <span class="c1">// !! Assumes variable fileURL contains a valid URL to a text file on the device,</span>
+    <span class="kd">var</span> <span class="nx">fileURL</span> <span class="o">=</span> <span class="nx">fileEntry</span><span class="p">.</span><span class="nx">toURL</span><span class="p">();</span>
+
+    <span class="kd">var</span> <span class="nx">success</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">r</span><span class="p">)</span> <span class="p">{</span>
+        <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"Successful upload..."</span><span class="p">);</span>
+        <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"Code = "</span> <span class="o">+</span> <span class="nx">r</span><span class="p">.</span><span class="nx">responseCode</span><span class="p">);</span>
+        <span class="c1">// displayFileData(fileEntry.fullPath + " (content uploaded to server)");</span>
+    <span class="p">}</span>
+
+    <span class="kd">var</span> <span class="nx">fail</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
+        <span class="nx">alert</span><span class="p">(</span><span class="s2">"An error has occurred: Code = "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">code</span><span class="p">);</span>
+    <span class="p">}</span>
+
+    <span class="kd">var</span> <span class="nx">options</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">FileUploadOptions</span><span class="p">();</span>
+    <span class="nx">options</span><span class="p">.</span><span class="nx">fileKey</span> <span class="o">=</span> <span class="s2">"file"</span><span class="p">;</span>
+    <span class="nx">options</span><span class="p">.</span><span class="nx">fileName</span> <span class="o">=</span> <span class="nx">fileURL</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="nx">fileURL</span><span class="p">.</span><span class="nx">lastIndexOf</span><span class="p">(</span><span class="s1">'/'</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">);</span>
+    <span class="nx">options</span><span class="p">.</span><span class="nx">mimeType</span> <span class="o">=</span> <span class="s2">"text/plain"</span><span class="p">;</span>
+
+    <span class="kd">var</span> <span class="nx">params</span> <span class="o">=</span> <span class="p">{};</span>
+    <span class="nx">params</span><span class="p">.</span><span class="nx">value1</span> <span class="o">=</span> <span class="s2">"test"</span><span class="p">;</span>
+    <span class="nx">params</span><span class="p">.</span><span class="nx">value2</span> <span class="o">=</span> <span class="s2">"param"</span><span class="p">;</span>
+
+    <span class="nx">options</span><span class="p">.</span><span class="nx">params</span> <span class="o">=</span> <span class="nx">params</span><span class="p">;</span>
+
+    <span class="kd">var</span> <span class="nx">ft</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">FileTransfer</span><span class="p">();</span>
+    <span class="c1">// SERVER must be a URL that can handle the request, like</span>
+    <span class="c1">// http://some.server.com/upload.php</span>
+    <span class="nx">ft</span><span class="p">.</span><span class="nx">upload</span><span class="p">(</span><span class="nx">fileURL</span><span class="p">,</span> <span class="nb">encodeURI</span><span class="p">(</span><span class="nx">SERVER</span><span class="p">),</span> <span class="nx">success</span><span class="p">,</span> <span class="nx">fail</span><span class="p">,</span> <span class="nx">options</span><span class="p">);</span>
+<span class="p">};</span>
+</code></pre></div>
+<h2>Download the uploaded file <a name="downloadFile"></a></h2>
+
+<p>To download the image you just uploaded, you will need a valid URL that can handle the request, for example, http://some.server.com/download.php. Again, the success handler for the FileTransfer.download method receives a FileEntry object. The main difference here from previous examples is that we call FileReader.readAsText to read the result of the download operation, because we uploaded a file with text content.</p>
+<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kd">function</span> <span class="nx">download</span><span class="p">(</span><span class="nx">fileEntry</span><span class="p">,</span> <span class="nx">uri</span><span class="p">)</span> <span class="p">{</span>
+
+    <span class="kd">var</span> <span class="nx">fileTransfer</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">FileTransfer</span><span class="p">();</span>
+    <span class="kd">var</span> <span class="nx">fileURL</span> <span class="o">=</span> <span class="nx">fileEntry</span><span class="p">.</span><span class="nx">toURL</span><span class="p">();</span>
+
+    <span class="nx">fileTransfer</span><span class="p">.</span><span class="nx">download</span><span class="p">(</span>
+        <span class="nx">uri</span><span class="p">,</span>
+        <span class="nx">fileURL</span><span class="p">,</span>
+        <span class="kd">function</span> <span class="p">(</span><span class="nx">entry</span><span class="p">)</span> <span class="p">{</span>
+            <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"Successful download..."</span><span class="p">);</span>
+            <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"download complete: "</span> <span class="o">+</span> <span class="nx">entry</span><span class="p">.</span><span class="nx">toURL</span><span class="p">());</span>
+            <span class="nx">readFile</span><span class="p">(</span><span class="nx">entry</span><span class="p">);</span>
+        <span class="p">},</span>
+        <span class="kd">function</span> <span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
+            <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"download error source "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">source</span><span class="p">);</span>
+            <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"download error target "</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">target</span><span class="p">);</span>
+            <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"upload error code"</span> <span class="o">+</span> <span class="nx">error</span><span class="p">.</span><span class="nx">code</span><span class="p">);</span>
+        <span class="p">},</span>
+        <span class="kc">null</span><span class="p">,</span> <span class="c1">// or, pass false</span>
+        <span class="p">{</span>
+            <span class="c1">//headers: {</span>
+            <span class="c1">//    "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="</span>
+            <span class="c1">//}</span>
+        <span class="p">}</span>
+    <span class="p">);</span>
+<span class="p">}</span>
+</code></pre></div>
+<p>In the readFile function, call the <code>readAsText</code> method of the FileReader object.</p>
+<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kd">function</span> <span class="nx">readFile</span><span class="p">(</span><span class="nx">fileEntry</span><span class="p">)</span> <span class="p">{</span>
+    <span class="nx">fileEntry</span><span class="p">.</span><span class="nx">file</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">file</span><span class="p">)</span> <span class="p">{</span>
+        <span class="kd">var</span> <span class="nx">reader</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">FileReader</span><span class="p">();</span>
+
+        <span class="nx">reader</span><span class="p">.</span><span class="nx">onloadend</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+
+            <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">"Successful file read: "</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">result</span><span class="p">);</span>
+            <span class="c1">// displayFileData(fileEntry.fullPath + ": " + this.result);</span>
+
+        <span class="p">};</span>
+
+        <span class="nx">reader</span><span class="p">.</span><span class="nx">readAsText</span><span class="p">(</span><span class="nx">file</span><span class="p">);</span>
+
+    <span class="p">},</span> <span class="nx">onErrorReadFile</span><span class="p">);</span>
+<span class="p">}</span>
+</code></pre></div>
 
                 </div>
             </div>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message