Android 如何不在缓存中保存图像
我想使用相机以角度模式保存图像,但图像始终保存在应用程序的缓存文件夹中: 以下是拍照的代码:Android 如何不在缓存中保存图像,android,ios,angular,typescript,ionic-framework,Android,Ios,Angular,Typescript,Ionic Framework,我想使用相机以角度模式保存图像,但图像始终保存在应用程序的缓存文件夹中: 以下是拍照的代码: image: any = ''; async openCam() { const options: CameraOptions = { quality: 50, destinationType: this.camera.DestinationType.NATIVE_URI, encodingType: this.camera.EncodingType.JPEG,
image: any = '';
async openCam() {
const options: CameraOptions = {
quality: 50,
destinationType: this.camera.DestinationType.NATIVE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
};
try {
const imageData = await this.camera.getPicture(options);
return this.image = (window as any).Ionic.WebView.convertFileSrc(imageData);
} catch (err) {
// Handle error
if (JSON.stringify(err) !== '"No Image Selected"') {
alert('error ' + JSON.stringify(err));
}
}
}
以下是保存和获取图像的代码:
async saveItem(item, value, secondValue) {
this.nativeStorage.setItem(item, { one: value, two: secondValue })
.then(() => console.log('Stored item!'))
.catch(error => console.error('Error storing item', error));
}
async getItem(item) {
return await this.nativeStorage.getItem(item);
}
我希望能够将图像存储在应用程序的文件中,而不是缓存中
对于您的回答如果您不想在缓存中存储数据,请不要使用在缓存中存储数据的插件!使用而不是本地存储。我可能解释得不好。函数getPicture()将图像保存在缓存中,因此imageData指向缓存。