Ionic 2 Cordova Android图像上传错误:

时间:2018-08-03 09:20:21

标签: android file cordova ionic-framework ionic2

我试图以sudo hwclock -D -r的形式从图库或android的照相机中获取图像 然后使用fileURI

将其转换为文件
resolveLocalFilesystemUrl

然后:

const options: CameraOptions = {
  quality: 100,
  correctOrientation: true,
  destinationType: this.camera.DestinationType.FILE_URI,
  encodingType: this.camera.EncodingType.JPEG,
  mediaType: this.camera.MediaType.PICTURE,
  sourceType: sourceType
}

我得到的图像数据是:

   // Get the picture
this.camera.getPicture(options).then((imageData) => {
  console.log("now here !");
  console.log(imageData);

我遇到的错误是 “ this.file.resolveLocalFilesystemUrl(imageData)”

  file:///storage/emulated/0/Android/data/io.ionic.app5/cache/IMG-20180802-WA0004.jpg?1533286934006

错误是:

let loading = this.loadingCtrl.create();
loading.present();
console.log(imageData);


// Resolve the picture URI to a file
this.file.resolveLocalFilesystemUrl(imageData).then(oneFile => {

    // Convert the File to an ArrayBuffer for upload
    this.file.readAsArrayBuffer(this.file.tempDirectory, oneFile.name).then(realFile => {
        let type = 'jpg';
        let newName = this.awsProvider.randomString(6) + new Date().getTime() + '.' + type;

0 个答案:

没有答案