【发布时间】:2016-04-01 18:50:01
【问题描述】:
我正在使用 ionic 和 ngCordova 相机插件来调用我的相机,并且我正在获取 base64 格式的图像我不需要保存图像,但我需要发送图像以不用作 base64。我需要将它作为文件格式发送有没有什么方法可以将图像作为文件发送给我的支持是 c#。
这是我的 html 的样子
<img ng-show="imgURI !== undefined" ng-src="{{imgURI}}">
<img ng-show="imgURI === undefined" ng-src="http://placehold.it/250x250">
<button class="button" ng-click="takePicture()">Take Picture</button>
我的 app.js 文件
$scope.takePicture = function(){
var options = {
quality: 50,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 250,
targetHeight: 250,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
correctOrientation:true
};
$cordovaCamera.getPicture(options).then(function(imageData) {
console.log(imageData);
$scope.imgURI = "data:image/jpeg;base64," + imageData;
}, function(err) {
// error
});
};
}, false);
在我的 imageData 中,我有 base64 值,有没有办法将 $scope.imgURI 转换为文件,这样我就可以发送我的图像来服务了。
【问题讨论】:
标签: angularjs image ionic-framework cordova-plugins ngcordova