added download() to the filetransfer

This commit is contained in:
Alexander Keller
2011-11-26 18:16:44 +01:00
parent 853a734f82
commit 8904c67fb5
2 changed files with 313 additions and 257 deletions

View File

@@ -83,6 +83,17 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
PhoneGap.exec(successCallback, errorCallback, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode]);
};
/**
* Downloads a file form a given URL and saves it to the specified directory.
* @param sourceUrl {String} URL of the server to receive the file
* @param targetFile {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(sourceUrl, targetFile, successCallback, errorCallback) {
PhoneGap.exec(successCallback, errorCallback, 'FileTransfer', 'download', [targetFile, sourceUrl]);
};
/**
* Options to customize the HTTP request used to upload files.
* @constructor