Я получил ответ от реализации WebChromeClient в Android
let webview: WebView = this.webViewRef.nativeElement;
let myWebChromeClient: MyWebChromeClient = new MyWebChromeClient();
webview.android.setWebChromeClient(myWebChromeClient);
и класс MyWebChromeClient находится здесь
import * as imagepicker from "nativescript-imagepicker";
import * as fs from "file-system";
export class MyWebChromeClient extends android.webkit.WebChromeClient {
file_path:string;
constructor() {
super();
return global.__native(this);
}
onShowFileChooser(webView,filePathCallback,fileChooserParams) {
this.filepathCallback(filePathCallback);
return true;
}
filepathCallback(filePathCallback)
{
let context = imagepicker.create({
mode: "single",
mediaType: imagepicker.ImagePickerMediaType.Any
});
this.startSelection(context,filePathCallback);
}
startSelection(context,filePathCallback) {
context.authorize().then(() => {
return context.present();
})
.then((selection) => {
selection.forEach((selected) => {
let path = selected.android;
let file = fs.File.fromPath(path);
this.file_path = file.path;
this.file_path = "file://" + this.file_path;
let results = Array.create(android.net.Uri, 1);
results[0] = android.net.Uri.parse(this.file_path);
filePathCallback.onReceiveValue(results);
return this.file_path;
});
}).catch(function (e) {
console.log(e);
});
}
}