mirror of
https://github.com/apache/cordova-plugin-file-transfer.git
synced 2024-10-07 00:08:12 +08:00
CB-6050: Use instance method on actual file plugin object to get FileEntry to return on download
This commit is contained in:
parent
31ac00d3ae
commit
35f80e42ec
@ -11,7 +11,7 @@
|
|||||||
<issue>https://issues.apache.org/jira/browse/CB/component/12320650</issue>
|
<issue>https://issues.apache.org/jira/browse/CB/component/12320650</issue>
|
||||||
|
|
||||||
<!-- dependency id="org.apache.cordova.file@1" /-->
|
<!-- dependency id="org.apache.cordova.file@1" /-->
|
||||||
<dependency id="org.apache.cordova.file" />
|
<dependency id="org.apache.cordova.file" version="1.0.1" />
|
||||||
|
|
||||||
<js-module src="www/FileTransferError.js" name="FileTransferError">
|
<js-module src="www/FileTransferError.js" name="FileTransferError">
|
||||||
<clobbers target="window.FileTransferError" />
|
<clobbers target="window.FileTransferError" />
|
||||||
|
@ -797,9 +797,21 @@ public class FileTransfer extends CordovaPlugin {
|
|||||||
Log.d(LOG_TAG, "Saved file: " + target);
|
Log.d(LOG_TAG, "Saved file: " + target);
|
||||||
|
|
||||||
// create FileEntry object
|
// 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) {
|
} catch (FileNotFoundException e) {
|
||||||
JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source, target, connection);
|
JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source, target, connection);
|
||||||
Log.e(LOG_TAG, error.toString(), e);
|
Log.e(LOG_TAG, error.toString(), e);
|
||||||
|
Loading…
Reference in New Issue
Block a user