So i made a cordova app, i added android platform and made a simple html with an imput field
Here's another work around if you don't want to modify plugin source code. Create a separate control for taking pictures. Set the control's click event to the following handler:
(event) => {
event.stopPropagation();
Camera.sourceType = Camera.PictureSourceType.CAMERA;
const onCameraSuccess = (imgURL) => {
window.resolveLocalFileSystemURL(imgURL, (entry) => {
const onFileSuccess = (file) => this._onSelectMultipleFiles(event, file);
const onFileFail = (error) => console.log(error);
entry.file(onFileSuccess, onFileFail);
});
console.log("picture retrieved successfully");
};
const onCameraFail = () => {
console.log("picture retrieval failed");
};
navigator.camera.getPicture(onCameraSuccess, onCameraFail, {
quality: 100,
destinationType: Camera.DestinationType.FILE_URI,
});
}
This uses cordova-plugin-camera to launch the camera app when the control is clicked, and calls resolveLocalFileSystemURL from cordova-plugin-file to convert the image URL returned by the camera into a File object to be processed by my _onSelectMultipleFiles method. see example from cordova docs
Note that this implementation is specific to my project, so you may not need to call resolveLocalFileSystemURL depending on how you intend to use the image URL passed in the onSuccess callback of camera.getPicture.
Obviously the down side to this is the need to use two controls: one for retrieving images from file, the other for retrieving images from the camera.