简体   繁体   English

Phonegap:Camera.getPicture仅返回NATIVE_URI

[英]Phonegap: Camera.getPicture only returns NATIVE_URI

I'm trying to get an image via phonegap from SAVEDPHOTOSALBUM and present it on the screen. 我正在尝试通过phonegap从SAVEDPHOTOSALBUM获取图像并将其显示在屏幕上。 Like phonegap docs say, I use getPicture like this: 就像phonegap文档所说的那样,我使用getPicture像这样:

navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
    destinationType: Camera.DestinationType.DATA_URL,
    sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM,
    encodingType: Camera.EncodingType.JPEG
 });

On iOS-Devices it works just fine. 在iOS设备上,它可以正常工作。 I'm getting the imageData as Base64 and can easily print it out via img-Tag. 我将imageData作为Base64获得,可以通过img-Tag轻松将其打印出来。 On Android-Devices (Nexus7, Nexus10 both KitKat) it only returns the native_uri. 在Android设备(Nexus7,Nexus10和KitKat)上,它仅返回native_uri。 Something like that: 像这样:

content://com.android.providers.media.documents/document/image%3A9539

So my question is, how can I retrieve the image from SAVEDPHOTOSABUM as Base64 and not as URI ? 所以我的问题是,如何从SAVEDPHOTOSABUM作为Base64而不是URI检索图像? Why does Phonegap not return it correctly ? 为什么Phonegap无法正确返回?

this plugin is used to calculate base64 encoding of a file located on file system: 插件用于计算文件系统上文件的base64编码:

window.plugins.Base64.encodeFile(filePath, function(base64){
        console.log('file base64 encoding: ' + base64);
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Phonegap camera.getPicture上传问题 - Phonegap camera.getPicture issues with upload Phonegap camera.getPicture imageURI仅临时在Cache文件夹中,如何获取永久imageSRC - Phonegap camera.getPicture imageURI only temp in Cache folder, how can I get permanent imageSRC 无法使用camera.getPicture phonegap android获取图像URL - can't get image url with camera.getPicture phonegap android 我如何从PhoneGap camera.getPicture获取File对象? - How would I get a File object from PhoneGap camera.getPicture? 在调用camera.getPicture之前如何检查相机权限 - How to check camera permissions before invoking camera.getPicture PhoneGap Camera,无法读取未定义的属性'getPicture' - PhoneGap Camera , Cannot read property 'getPicture' of undefined Phonegap navigator.camera.getPicture内存警告 - Phonegap navigator.camera.getPicture memory warning 将Cordova camera.getPicture文件传递到AWS S3(JS SDK) - Passing a Cordova camera.getPicture File to AWS S3 (JS SDK) DevExtreme / Phonegap相机插件:“无法读取未定义的道具'getPicture'” - DevExtreme/Phonegap camera plugin: “Cannot read propetry 'getPicture' of undefined” 无法在iOS phonegap adobe构建上使用navigator.camera.getPicture - Can't use navigator.camera.getPicture on iOS phonegap adobe build
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM