Urigo / Ionic2CLI-Meteor-WhatsApp

WhatsApp Clone tutorial with Ionic 2.0 CLI and Meteor Server
https://www.angular-meteor.com/tutorials/whatsapp2/ionic/setup
163 stars 185 forks source link

step 14, Cannot get picture file blob from camera in iPhone #176

Open sitexa opened 6 years ago

sitexa commented 6 years ago

1,From messages-attachments.ts: sendPicture(camera:boolean) -> this.pictureService.getPicture(camera,false) ; 2, From picture.ts: getPicture(camera:boolean,crop:boolean):Promise<File>

return this.camera.getPicture(<CameraOptions>{
      destinationType: 1,//image file URI
      quality: 50,
      correctOrientation: true,
      saveToPhotoAlbum: true,
      sourceType: camera ? 1 : 0, //from camera
      mediaType: 2 //picture and video
    })
      .then((fileURI) => {
        return crop ? this.crop.crop(fileURI, {quality: 50}) : fileURI;
      })
      .then((croppedFileURI) => {
        return this.convertURLtoBlob(croppedFileURI); //line-A
      });

No Promise<File> returned to caller. I doubt if the line this.convertURLtoBlob(...) don't work correct, but don't knnow why and have no way to debug. Can anybody help?

IvanLjubicic commented 6 years ago

Actually, I have similar problem with picture upload on iOs. I had an error like this: Not allowed to load local resource : file:///var/mobile I used this solution

https://stackoverflow.com/questions/44910984/ionic-3-file-uri-not-allowed-to-load-local-resource-ios

and app got through this part of code, but eventually it raises exception in this method

`upload(blob: File): Promise { return new Promise((resolve, reject) => { const metadata: any = _.pick(blob, 'name', 'type', 'size');

  if (!metadata.name) {
    metadata.name = DEFAULT_PICTURE_URL;
  }

  const upload = new UploadFS.Uploader({
    data: blob,
    file: metadata,
    store: PicturesStore,
    onComplete: resolve,
    onError: reject
  });

  upload.start();
});

}`

It seems like on iOs code in this method cannot read name and size of picture, so it crashes later on while uploading.

Any suggestions would be nice.