mirror of
https://github.com/apache/cordova-plugin-file-transfer.git
synced 2026-04-28 00:02:49 +08:00
CB-6050: Use instance method on actual file plugin object to get FileEntry to return on download
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user