Ionic2CLI-Meteor-WhatsApp icon indicating copy to clipboard operation
Ionic2CLI-Meteor-WhatsApp copied to clipboard

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

Open sitexa opened this issue 7 years ago • 1 comments

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?

sitexa avatar Dec 24 '17 13:12 sitexa

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.

IvanLjubicic avatar Jan 02 '18 21:01 IvanLjubicic