如何不将图像保存在缓存中

时间:2019-09-26 13:18:05

标签: android ios angular typescript ionic-framework

我想使用Camera以角度保存图像,但是图像始终保存在我的应用程序的缓存文件夹中:

http://localhost/_app_file_/storage/emulated/0/Android/data/io.ionic.starter/cache/my_image.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);
}

我希望能够将图像存储在应用程序的文件中,而不是在缓存中 请输入您的答复

0 个答案:

没有答案