[英]Cordova Plugin: Unable to retrieve path to picture
Searching for a solution to the following problem for a while and can't seem to find any solutions. 搜索以下问题的解决方案已有一段时间,似乎找不到任何解决方案。 Any help is welcome. 欢迎任何帮助。
The camera plugin of cordova returns the following error when trying to access a picture using the camera. 尝试使用相机访问图片时,cordova的相机插件返回以下错误。
Unable to retrieve path to picture! 无法获取图片的路径!
I tried FILE_URI and DATA_URL. 我尝试了FILE_URI和DATA_URL。
I use cordova version 5.0.0 and cordova-plugin-camera. 我使用5.0.0版的cordova和cordova-plugin-camera。
The following path fails eg 以下路径失败,例如
/storage/emulated/0/Download/horse-331746_640.jpg
The following path functions eg 以下路径功能例如
/storage/emulated/0/WhatsApp/Media/WhatsApp Images/IMG-2015019-WA0000.JPG
My Function: 我的职能:
function captureNow(bGallery){
if(bGallery === true){
navigator.camera.getPicture(onCapturePhoto, cameraOnFail, {
quality: 100,
correctOrientation: 1,
targetWidth: 500,
targetHeight: 500,
encodingType: Camera.EncodingType.JPEG,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY
});
} else {
navigator.camera.getPicture(onCapturePhoto, cameraOnFail, {
quality: 100,
correctOrientation: 1,
targetWidth: 500,
targetHeight: 500,
encodingType: Camera.EncodingType.JPEG,
destinationType: Camera.DestinationType.FILE_URI
});
}
}
The fail message Unable to retrieve path to picture! 失败消息无法检索图片的路径! is caused by hardcoded requirement in the plugin that image selected from gallery must have either image/jpeg
or image/png
mime type (see cordova-plugin-camera: CameraLauncher.java ) 是由插件中的硬编码要求引起的,即从图库中选择的图像必须具有image/jpeg
或image/png
MIME类型(请参阅cordova-plugin-camera:CameraLauncher.java )
While you are getting this message for JPEG image, I'd say that: 当您收到有关JPEG图像的消息时,我会这样说:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.