mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 15:12:51 +08:00
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/cordova-android
This commit is contained in:
commit
12d06bd727
@ -94,12 +94,18 @@ public class FileHelper {
|
||||
if (uriString.startsWith("content:")) {
|
||||
Uri uri = Uri.parse(uriString);
|
||||
return cordova.getActivity().getContentResolver().openInputStream(uri);
|
||||
} else if (uriString.startsWith("file:///android_asset/")) {
|
||||
} else if (uriString.startsWith("file://")) {
|
||||
int question = uriString.indexOf("?");
|
||||
if (question > -1) {
|
||||
uriString = uriString.substring(0,question);
|
||||
}
|
||||
if (uriString.startsWith("file:///android_asset/")) {
|
||||
Uri uri = Uri.parse(uriString);
|
||||
String relativePath = uri.getPath().substring(15);
|
||||
return cordova.getActivity().getAssets().open(relativePath);
|
||||
} else if (uriString.startsWith("file://")) {
|
||||
} else {
|
||||
return new FileInputStream(getRealPath(uriString, cordova));
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -855,20 +855,15 @@ public class FileTransfer extends CordovaPlugin {
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
private InputStream getPathFromUri(String path) throws FileNotFoundException {
|
||||
if (path.startsWith("content:")) {
|
||||
Uri uri = Uri.parse(path);
|
||||
return cordova.getActivity().getContentResolver().openInputStream(uri);
|
||||
}
|
||||
else if (path.startsWith("file://")) {
|
||||
int question = path.indexOf("?");
|
||||
if (question == -1) {
|
||||
return new FileInputStream(path.substring(7));
|
||||
} else {
|
||||
return new FileInputStream(path.substring(7, question));
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
InputStream stream = FileHelper.getInputStreamFromUriString(path, cordova);
|
||||
if (stream == null) {
|
||||
return new FileInputStream(path);
|
||||
} else {
|
||||
return stream;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user