From 35f80e42ec0a0343022bffa88b1cbd2e68f0fc3f Mon Sep 17 00:00:00 2001 From: Ian Clelland Date: Tue, 18 Feb 2014 15:25:01 -0500 Subject: [PATCH] CB-6050: Use instance method on actual file plugin object to get FileEntry to return on download --- plugin.xml | 2 +- src/android/FileTransfer.java | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/plugin.xml b/plugin.xml index a1a9ebd..d93cdac 100644 --- a/plugin.xml +++ b/plugin.xml @@ -11,7 +11,7 @@ https://issues.apache.org/jira/browse/CB/component/12320650 - + diff --git a/src/android/FileTransfer.java b/src/android/FileTransfer.java index 7ea23ca..e370c5f 100644 --- a/src/android/FileTransfer.java +++ b/src/android/FileTransfer.java @@ -797,9 +797,21 @@ public class FileTransfer extends CordovaPlugin { Log.d(LOG_TAG, "Saved file: " + target); // create FileEntry object - JSONObject fileEntry = FileUtils.getEntry(file); + FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File"); + if (filePlugin != null) { + JSONObject fileEntry = filePlugin.getEntryForFile(file); + if (fileEntry != null) { + result = new PluginResult(PluginResult.Status.OK, fileEntry); + } else { + JSONObject error = createFileTransferError(CONNECTION_ERR, source, target, connection); + Log.e(LOG_TAG, "File plugin cannot represent download path"); + result = new PluginResult(PluginResult.Status.IO_EXCEPTION, error); + } + } else { + Log.e(LOG_TAG, "File plugin not found; cannot save downloaded file"); + result = new PluginResult(PluginResult.Status.ERROR, "File plugin not found; cannot save downloaded file"); + } - result = new PluginResult(PluginResult.Status.OK, fileEntry); } catch (FileNotFoundException e) { JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source, target, connection); Log.e(LOG_TAG, error.toString(), e);