You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by be...@apache.org on 2013/06/25 00:25:43 UTC
git commit: [CB-3729] first pass wp8 support
Updated Branches:
refs/heads/master 00ffa38bb -> 2b2909342
[CB-3729] first pass wp8 support
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/commit/2b290934
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/2b290934
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/2b290934
Branch: refs/heads/master
Commit: 2b290934233f7353f3dafa53b7fa1de45796f9c1
Parents: 00ffa38
Author: Benn Mapes <be...@gmail.com>
Authored: Mon Jun 24 15:25:23 2013 -0700
Committer: Benn Mapes <be...@gmail.com>
Committed: Mon Jun 24 15:25:23 2013 -0700
----------------------------------------------------------------------
plugin.xml | 21 ++
src/wp8/FileTransfer.cs | 526 +++++++++++++++++++++++++++++++++++++++++++
www/wp/FileTransfer.js | 123 ++++++++++
3 files changed, 670 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/2b290934/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 34b9305..cc837ff 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -52,6 +52,27 @@ id="org.apache.cordova.core.FileTransfer" version="0.1.0">
</config-file>
<source-file src="src/wp7/FileTransfer.cs" />
+
+ <js-module src="www/wp/FileTransfer.js" name="FileTransfer1">
+ <clobbers target="window.FileTransfer" />
+ </js-module>
+
+ </platform>
+
+ <!-- wp8 -->
+ <platform name="wp8">
+ <config-file target="config.xml" parent="/*">
+ <feature name="FileTransfer">
+ <param name="wp-package" value="FileTransfer"/>
+ </feature>
+ </config-file>
+
+ <source-file src="src/wp8/FileTransfer.cs" />
+
+ <js-module src="www/wp/FileTransfer.js" name="FileTransfer1">
+ <clobbers target="window.FileTransfer" />
+ </js-module>
+
</platform>
</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/2b290934/src/wp8/FileTransfer.cs
----------------------------------------------------------------------
diff --git a/src/wp8/FileTransfer.cs b/src/wp8/FileTransfer.cs
new file mode 100644
index 0000000..e585895
--- /dev/null
+++ b/src/wp8/FileTransfer.cs
@@ -0,0 +1,526 @@
+/*
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.IO.IsolatedStorage;
+using System.Net;
+using System.Runtime.Serialization;
+using System.Windows;
+using System.Security;
+using System.Diagnostics;
+
+namespace WPCordovaClassLib.Cordova.Commands
+{
+ public class FileTransfer : BaseCommand
+ {
+ public class DownloadRequestState
+ {
+ // This class stores the State of the request.
+ public HttpWebRequest request;
+ public DownloadOptions options;
+
+ public DownloadRequestState()
+ {
+ request = null;
+ options = null;
+ }
+ }
+
+ /// <summary>
+ /// Boundary symbol
+ /// </summary>
+ private string Boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x");
+
+ // Error codes
+ public const int FileNotFoundError = 1;
+ public const int InvalidUrlError = 2;
+ public const int ConnectionError = 3;
+
+ /// <summary>
+ /// Options for downloading file
+ /// </summary>
+ [DataContract]
+ public class DownloadOptions
+ {
+ /// <summary>
+ /// File path to download to
+ /// </summary>
+ [DataMember(Name = "filePath", IsRequired = true)]
+ public string FilePath { get; set; }
+
+ /// <summary>
+ /// Server address to the file to download
+ /// </summary>
+ [DataMember(Name = "url", IsRequired = true)]
+ public string Url { get; set; }
+ }
+
+ /// <summary>
+ /// Options for uploading file
+ /// </summary>
+ [DataContract]
+ public class UploadOptions
+ {
+ /// <summary>
+ /// File path to upload
+ /// </summary>
+ [DataMember(Name = "filePath", IsRequired = true)]
+ public string FilePath { get; set; }
+
+ /// <summary>
+ /// Server address
+ /// </summary>
+ [DataMember(Name = "server", IsRequired = true)]
+ public string Server { get; set; }
+
+ /// <summary>
+ /// File key
+ /// </summary>
+ [DataMember(Name = "fileKey")]
+ public string FileKey { get; set; }
+
+ /// <summary>
+ /// File name on the server
+ /// </summary>
+ [DataMember(Name = "fileName")]
+ public string FileName { get; set; }
+
+ /// <summary>
+ /// File Mime type
+ /// </summary>
+ [DataMember(Name = "mimeType")]
+ public string MimeType { get; set; }
+
+
+ /// <summary>
+ /// Additional options
+ /// </summary>
+ [DataMember(Name = "params")]
+ public string Params { get; set; }
+
+ /// <summary>
+ /// Flag to recognize if we should trust every host (only in debug environments)
+ /// </summary>
+ [DataMember(Name = "debug")]
+ public bool Debug { get; set; }
+
+ /// <summary>
+ /// Creates options object with default parameters
+ /// </summary>
+ public UploadOptions()
+ {
+ this.SetDefaultValues(new StreamingContext());
+ }
+
+ /// <summary>
+ /// Initializes default values for class fields.
+ /// Implemented in separate method because default constructor is not invoked during deserialization.
+ /// </summary>
+ /// <param name="context"></param>
+ [OnDeserializing()]
+ public void SetDefaultValues(StreamingContext context)
+ {
+ this.FileKey = "file";
+ this.FileName = "image.jpg";
+ this.MimeType = "image/jpeg";
+ }
+
+ }
+
+ /// <summary>
+ /// Uploading response info
+ /// </summary>
+ [DataContract]
+ public class FileUploadResult
+ {
+ /// <summary>
+ /// Amount of sent bytes
+ /// </summary>
+ [DataMember(Name = "bytesSent")]
+ public long BytesSent { get; set; }
+
+ /// <summary>
+ /// Server response code
+ /// </summary>
+ [DataMember(Name = "responseCode")]
+ public long ResponseCode { get; set; }
+
+ /// <summary>
+ /// Server response
+ /// </summary>
+ [DataMember(Name = "response", EmitDefaultValue = false)]
+ public string Response { get; set; }
+
+ /// <summary>
+ /// Creates FileUploadResult object with response values
+ /// </summary>
+ /// <param name="bytesSent">Amount of sent bytes</param>
+ /// <param name="responseCode">Server response code</param>
+ /// <param name="response">Server response</param>
+ public FileUploadResult(long bytesSent, long responseCode, string response)
+ {
+ this.BytesSent = bytesSent;
+ this.ResponseCode = responseCode;
+ this.Response = response;
+ }
+ }
+
+ /// <summary>
+ /// Represents transfer error codes for callback
+ /// </summary>
+ [DataContract]
+ public class FileTransferError
+ {
+ /// <summary>
+ /// Error code
+ /// </summary>
+ [DataMember(Name = "code", IsRequired = true)]
+ public int Code { get; set; }
+
+ /// <summary>
+ /// The source URI
+ /// </summary>
+ [DataMember(Name = "source", IsRequired = true)]
+ public string Source { get; set; }
+
+ /// <summary>
+ /// The target URI
+ /// </summary>
+ [DataMember(Name = "target", IsRequired = true)]
+ public string Target { get; set; }
+
+ /// <summary>
+ /// The http status code response from the remote URI
+ /// </summary>
+ [DataMember(Name = "http_status", IsRequired = true)]
+ public int HttpStatus { get; set; }
+
+ /// <summary>
+ /// Creates FileTransferError object
+ /// </summary>
+ /// <param name="errorCode">Error code</param>
+ public FileTransferError(int errorCode)
+ {
+ this.Code = errorCode;
+ this.Source = null;
+ this.Target = null;
+ this.HttpStatus = 0;
+ }
+ public FileTransferError(int errorCode, string source, string target, int status)
+ {
+ this.Code = errorCode;
+ this.Source = source;
+ this.Target = target;
+ this.HttpStatus = status;
+ }
+ }
+
+ /// <summary>
+ /// Upload options
+ /// </summary>
+ private UploadOptions uploadOptions;
+
+ /// <summary>
+ /// Bytes sent
+ /// </summary>
+ private long bytesSent;
+
+ /// <summary>
+ /// sends a file to a server
+ /// </summary>
+ /// <param name="options">Upload options</param>
+ public void upload(string options)
+ {
+ Debug.WriteLine("options = " + options);
+ options = options.Replace("{}", "null");
+
+ try
+ {
+ try
+ {
+ string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
+ uploadOptions = JSON.JsonHelper.Deserialize<UploadOptions>(args[0]);
+ }
+ catch (Exception)
+ {
+ DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
+ return;
+ }
+
+ Uri serverUri;
+ try
+ {
+ serverUri = new Uri(uploadOptions.Server);
+ }
+ catch (Exception)
+ {
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(InvalidUrlError, uploadOptions.Server, null, 0)));
+ return;
+ }
+ HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(serverUri);
+ webRequest.ContentType = "multipart/form-data;boundary=" + Boundary;
+ webRequest.Method = "POST";
+ webRequest.BeginGetRequestStream(WriteCallback, webRequest);
+ }
+ catch (Exception)
+ {
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(ConnectionError)));
+ }
+ }
+
+ public void download(string options)
+ {
+ DownloadOptions downloadOptions = null;
+ HttpWebRequest webRequest = null;
+
+ try
+ {
+ string[] optionStrings = JSON.JsonHelper.Deserialize<string[]>(options);
+
+ downloadOptions = new DownloadOptions();// JSON.JsonHelper.Deserialize<DownloadOptions>(options);
+ downloadOptions.Url = optionStrings[0];
+ downloadOptions.FilePath = optionStrings[1];
+ }
+ catch (Exception)
+ {
+ DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
+ return;
+ }
+
+ try
+ {
+ webRequest = (HttpWebRequest)WebRequest.Create(downloadOptions.Url);
+ }
+ catch (Exception)
+ {
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(InvalidUrlError, downloadOptions.Url, null, 0)));
+ return;
+ }
+
+ if (downloadOptions != null && webRequest != null)
+ {
+ DownloadRequestState state = new DownloadRequestState();
+ state.options = downloadOptions;
+ state.request = webRequest;
+ webRequest.BeginGetResponse(new AsyncCallback(downloadCallback), state);
+ }
+
+
+
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="asynchronousResult"></param>
+ private void downloadCallback(IAsyncResult asynchronousResult)
+ {
+ DownloadRequestState reqState = (DownloadRequestState)asynchronousResult.AsyncState;
+ HttpWebRequest request = reqState.request;
+
+ try
+ {
+ HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
+
+ using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
+ {
+ // create the file if not exists
+ if (!isoFile.FileExists(reqState.options.FilePath))
+ {
+ var file = isoFile.CreateFile(reqState.options.FilePath);
+ file.Close();
+ }
+
+ using (FileStream fileStream = new IsolatedStorageFileStream(reqState.options.FilePath, FileMode.Open, FileAccess.Write, isoFile))
+ {
+ long totalBytes = response.ContentLength;
+ int bytesRead = 0;
+ using (BinaryReader reader = new BinaryReader(response.GetResponseStream()))
+ {
+
+ using (BinaryWriter writer = new BinaryWriter(fileStream))
+ {
+ int BUFFER_SIZE = 1024;
+ byte[] buffer;
+
+ while (true)
+ {
+ buffer = reader.ReadBytes(BUFFER_SIZE);
+ // fire a progress event ?
+ bytesRead += buffer.Length;
+ if (buffer.Length > 0)
+ {
+ writer.Write(buffer);
+ }
+ else
+ {
+ writer.Close();
+ reader.Close();
+ fileStream.Close();
+ break;
+ }
+ }
+ }
+
+ }
+
+
+ }
+ }
+ WPCordovaClassLib.Cordova.Commands.File.FileEntry entry = new WPCordovaClassLib.Cordova.Commands.File.FileEntry(reqState.options.FilePath);
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, entry));
+ }
+ catch (IsolatedStorageException)
+ {
+ // Trying to write the file somewhere within the IsoStorage.
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(FileNotFoundError)));
+ }
+ catch (SecurityException)
+ {
+ // Trying to write the file somewhere not allowed.
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(FileNotFoundError)));
+ }
+ catch (WebException webex)
+ {
+ // TODO: probably need better work here to properly respond with all http status codes back to JS
+ // Right now am jumping through hoops just to detect 404.
+ if ((webex.Status == WebExceptionStatus.ProtocolError && ((HttpWebResponse)webex.Response).StatusCode == HttpStatusCode.NotFound) || webex.Status == WebExceptionStatus.UnknownError)
+ {
+ // Weird MSFT detection of 404... seriously... just give us the f(*&#$@ status code as a number ffs!!!
+ // "Numbers for HTTP status codes? Nah.... let's create our own set of enums/structs to abstract that stuff away."
+ // FACEPALM
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(ConnectionError, null, null, 404)));
+ }
+ else
+ {
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(ConnectionError)));
+ }
+ }
+ catch (Exception)
+ {
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(FileNotFoundError)));
+ }
+ }
+
+
+
+ /// <summary>
+ /// Read file from Isolated Storage and sends it to server
+ /// </summary>
+ /// <param name="asynchronousResult"></param>
+ private void WriteCallback(IAsyncResult asynchronousResult)
+ {
+ try
+ {
+ HttpWebRequest webRequest = (HttpWebRequest)asynchronousResult.AsyncState;
+ using (Stream requestStream = (webRequest.EndGetRequestStream(asynchronousResult)))
+ {
+ string lineStart = "--";
+ string lineEnd = Environment.NewLine;
+ byte[] boundaryBytes = System.Text.Encoding.UTF8.GetBytes(lineStart + Boundary + lineEnd);
+ string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"" + lineEnd + lineEnd + "{1}" + lineEnd;
+
+ if (uploadOptions.Params != null)
+ {
+
+ string[] arrParams = uploadOptions.Params.Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
+
+ foreach (string param in arrParams)
+ {
+ string[] split = param.Split('=');
+ string key = split[0];
+ string val = split[1];
+ requestStream.Write(boundaryBytes, 0, boundaryBytes.Length);
+ string formItem = string.Format(formdataTemplate, key, val);
+ byte[] formItemBytes = System.Text.Encoding.UTF8.GetBytes(formItem);
+ requestStream.Write(formItemBytes, 0, formItemBytes.Length);
+ }
+ requestStream.Write(boundaryBytes, 0, boundaryBytes.Length);
+ }
+ using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
+ {
+ if (!isoFile.FileExists(uploadOptions.FilePath))
+ {
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(FileNotFoundError, uploadOptions.Server, uploadOptions.FilePath, 0)));
+ return;
+ }
+
+ using (FileStream fileStream = new IsolatedStorageFileStream(uploadOptions.FilePath, FileMode.Open, isoFile))
+ {
+ string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"" + lineEnd + "Content-Type: {2}" + lineEnd + lineEnd;
+ string header = string.Format(headerTemplate, uploadOptions.FileKey, uploadOptions.FileName, uploadOptions.MimeType);
+ byte[] headerBytes = System.Text.Encoding.UTF8.GetBytes(header);
+ requestStream.Write(boundaryBytes, 0, boundaryBytes.Length);
+ requestStream.Write(headerBytes, 0, headerBytes.Length);
+ byte[] buffer = new byte[4096];
+ int bytesRead = 0;
+
+ while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
+ {
+ requestStream.Write(buffer, 0, bytesRead);
+ bytesSent += bytesRead;
+ }
+ }
+ byte[] endRequest = System.Text.Encoding.UTF8.GetBytes(lineEnd + lineStart + Boundary + lineStart + lineEnd);
+ requestStream.Write(endRequest, 0, endRequest.Length);
+ }
+ }
+ webRequest.BeginGetResponse(ReadCallback, webRequest);
+ }
+ catch (Exception)
+ {
+ Deployment.Current.Dispatcher.BeginInvoke(() =>
+ {
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, new FileTransferError(ConnectionError)));
+ });
+ }
+ }
+
+ /// <summary>
+ /// Reads response into FileUploadResult
+ /// </summary>
+ /// <param name="asynchronousResult"></param>
+ private void ReadCallback(IAsyncResult asynchronousResult)
+ {
+ try
+ {
+ HttpWebRequest webRequest = (HttpWebRequest)asynchronousResult.AsyncState;
+ using (HttpWebResponse response = (HttpWebResponse)webRequest.EndGetResponse(asynchronousResult))
+ {
+ using (Stream streamResponse = response.GetResponseStream())
+ {
+ using (StreamReader streamReader = new StreamReader(streamResponse))
+ {
+ string responseString = streamReader.ReadToEnd();
+ Deployment.Current.Dispatcher.BeginInvoke(() =>
+ {
+ DispatchCommandResult(new PluginResult(PluginResult.Status.OK, new FileUploadResult(bytesSent, (long)response.StatusCode, responseString)));
+ });
+ }
+ }
+ }
+ }
+ catch (Exception)
+ {
+ Deployment.Current.Dispatcher.BeginInvoke(() =>
+ {
+ FileTransferError transferError = new FileTransferError(ConnectionError, uploadOptions.Server, uploadOptions.FilePath, 403);
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, transferError));
+ });
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/2b290934/www/wp/FileTransfer.js
----------------------------------------------------------------------
diff --git a/www/wp/FileTransfer.js b/www/wp/FileTransfer.js
new file mode 100644
index 0000000..b2f8686
--- /dev/null
+++ b/www/wp/FileTransfer.js
@@ -0,0 +1,123 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var exec = require('cordova/exec'),
+ FileTransferError = require('cordova/plugin/FileTransferError');
+
+// Note that the only difference between this and the default implementation is the
+// object literal passed to exec() in upload - jm
+
+/**
+ * FileTransfer uploads a file to a remote server.
+ * @constructor
+ */
+var FileTransfer = function() {};
+
+/**
+* Given an absolute file path, uploads a file on the device to a remote server
+* using a multipart HTTP request.
+* @param filePath {String} Full path of the file on the device
+* @param server {String} URL of the server to receive the file
+* @param successCallback (Function} Callback to be invoked when upload has completed
+* @param errorCallback {Function} Callback to be invoked upon error
+* @param options {FileUploadOptions} Optional parameters such as file name and mimetype
+* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
+*/
+
+FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) {
+
+ // sanity parameter checking
+ if (!filePath || !server) throw new Error("FileTransfer.upload requires filePath and server URL parameters at the minimum.");
+ // check for options
+ var fileKey = null;
+ var fileName = null;
+ var mimeType = null;
+ var params = null;
+ var chunkedMode = true;
+
+ if (options) {
+ fileKey = options.fileKey;
+ fileName = options.fileName;
+ mimeType = options.mimeType;
+ if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
+ chunkedMode = options.chunkedMode;
+ }
+
+ // if options are specified, and NOT a string already, we will stringify it.
+ if(options.params && typeof options.params != typeof "") {
+ var arrParams = [];
+ for(var v in options.params) {
+ arrParams.push(v + "=" + options.params[v]);
+ }
+ params = encodeURI(arrParams.join("&"));
+ }
+ }
+
+ var fail = function(e) {
+ var error = new FileTransferError(e.code, e.source, e.target, e.http_status);
+ errorCallback(error);
+ };
+ exec(successCallback, fail, 'FileTransfer', 'upload', [{"filePath":filePath,
+ "server":server,
+ "fileKey":fileKey,
+ "fileName":fileName,
+ "mimeType":mimeType,
+ "params":params,
+ "trustAllHosts":trustAllHosts,
+ "chunkedMode":chunkedMode}]);
+};
+
+/**
+ * Downloads a file form a given URL and saves it to the specified directory.
+ * @param source {String} URL of the server to receive the file
+ * @param target {String} Full path of the file on the device
+ * @param successCallback (Function} Callback to be invoked when upload has completed
+ * @param errorCallback {Function} Callback to be invoked upon error
+ */
+
+FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) {
+ // sanity parameter checking
+ if (!source || !target) throw new Error("FileTransfer.download requires source URI and target URI parameters at the minimum.");
+ var win = function(result) {
+ var entry = null;
+ if (result.isDirectory) {
+ entry = new (require('cordova/plugin/DirectoryEntry'))();
+ }
+ else if (result.isFile) {
+ entry = new (require('cordova/plugin/FileEntry'))();
+ }
+ entry.isDirectory = result.isDirectory;
+ entry.isFile = result.isFile;
+ entry.name = result.name;
+ entry.fullPath = result.fullPath;
+ successCallback(entry);
+ };
+
+ var fail = function(e) {
+ var error = new FileTransferError(e.code, e.source, e.target, e.http_status);
+ errorCallback(error);
+ };
+
+ exec(win, errorCallback, 'FileTransfer', 'download', [source, target]);
+};
+
+
+module.exports = FileTransfer;