繁体   English   中英

Cordova相机插件:拍照时不显示照片

[英]Cordova camera plugin: Photo is not displayed when taking a picture

我正在使用Cordova相机插件,但遇到了问题。

使用时: sourceType: Camera.PictureSourceType.PHOTOLIBRARY我得到一个这个URL: content://media/external/images/media/1517

<img ng-src="{{image}}" alt="Description"/>上使用此网址时,一切正常

但是,当删除sourceType并用电话拍照时,返回的URI类似于: file:///storage/emulated/0/Android/data/com.ionicframework.myapp/cache/1454450218633.jpg

并且当此URI返回时,不显示图像。 有任何想法吗? 它在ionic框架和android设备上。

一些代码这是用于拍照的:

   function takePhoto() {
     var defer = $q.defer();

     navigator.camera.getPicture(function(imageData) {
       defer.resolve(imageData);
     }, function(err) {
       defer.reject(err)
     });

     return defer.promise;
   }

从以下位置调用此方法:

$scope.getImage = function() {
  cameraService.takePhoto().then(function(imageData){
    console.log(imageData);
    $scope.image = imageData;
  }).catch(function(err){
    console.log(err);
  })
}

以及提供商白名单:

$compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|file|blob|cdvfile|content):|data:image\//);

更新:

我可以通过使用Camera.DestinationType.DATA_URL来完成此操作,但是是否不能仅获取文件url并显示图像呢? 从库中选择照片时,它又可以工作了,但是拍摄新照片时却不能。

问题是livereload功能。 在不使用livereload的情况下运行应用程序,然后就可以从该路径加载picuter

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM