- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何显示用户使用 @ionic-native/camera
拍摄的 FILE_URI 图像在 ionic 3 中?
我可以使用 Ionic Native 的 Camera 获取 FILE_URI 图像 URL,结果如下:
file:///var/mobile/Containers/Data/Application/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/tmp/cdv_photo_005.jpg
<img src="{{profile.image}}"> // Never loads
DomSanitizer
来清理 URI在页面组件中:
<img [src]="domSanitizer.bypassSecurityTrustUrl(profile.image)"> // Never loads
最佳答案
从“ ionic 角”导入 { normalizeURL }; ionic3 <img> tag src
<img *ngIf="base64Image" src="{{base64Image}}"/>
openCamera(pictureSourceType: any) {
let options: CameraOptions = {
quality: 95,
destinationType: this.camera.DestinationType.FILE_URI,
sourceType: pictureSourceType,
encodingType: this.camera.EncodingType.PNG,
targetWidth: 400,
targetHeight: 400,
saveToPhotoAlbum: true,
correctOrientation: true
};
this.camera.getPicture(options).then(imageData => {
if (this.platform.is('ios')) {
this.base64Image = normalizeURL(imageData);
// Alternatively if the problem only occurs in ios and normalizeURL
// doesn't work for you then you can also use:
// this.base64Image= imageData.replace(/^file:\/\//, '');
}
else {
this.base64Image= "data:image/jpeg;base64," + imageData;
}
}, error => {
console.log('ERROR -> ' + JSON.stringify(error));
});
}
关于ionic-framework - 在 Ionic 3 中显示由 Native Camera 拍摄的 FILE_URI 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49478537/
我正在开发一个基于 phonegap 的应用程序,它具有文件传输功能。我正在使用 phonegap 相机插件来选择图像文件。该代码适用于“DestinationType.DATA_URL”。但我无法使
我需要一些关于如何获取文件名称的提示,该文件已由 cordova 相机插件选取/拍摄。这是代码,我有一张图片: var options = {destinationType: Camera.Desti
cordova 插件相机中的 FILE_URI 和 NATIVE_URI 有什么区别? 最佳答案 共有三个选项,据我了解它们因平台而异: Camera.DestinationType.FILE_URI
这是我的 HTML 代码 Upload 下面是我的组件代码 import { ViewController, Platform, normalizeURL } from 'ionic-angul
在 Android 上,我正在尝试使用 Google Drive API 上传 Cordova/Phonegap getPicture() 的输出:插入文件。有没有办法使用 FILE_URI 而不是
我正在使用相机拍摄图像并进行预览。它需要发送到服务器,所以我使用“FILE_URI”的目标类型。当我在 android 上运行它时它工作,但我在 ios 10.3.1 上运行它时遇到此错误 不允许加载
如何显示用户使用 @ionic-native/camera 拍摄的 FILE_URI 图像在 ionic 3 中? 我可以使用 Ionic Native 的 Camera 获取 FILE_URI 图像
在 Kitkat navigator.camera.getPicture 返回这样的 Uri 之前 content://media/external/images/media/3951。 但是在 Ki
我是一名优秀的程序员,十分优秀!