jmarshall-com opened a new issue #666:
URL: https://github.com/apache/cordova-plugin-camera/issues/666


   <!--
   Please have a look at the issue templates you get when you click "New issue" 
in the GitHub UI.
   We very much prefer issues created by using one of these templates.
   -->
   
   ### Issue Type
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] Bug Report
   - [ ] Feature Request
   - [x] Support Question
   
   ## Description
   Using Cordova 10.0.0 and cordova-plugin-camera 5.0.0, when I call 
camera.getPicture() and use FileReader.readAsArrayBuffer() on the resulting 
FILE_URI, the camera app seems to run OK but the result is {}, i.e. an empty 
object.  This is when the saveToPhotoAlbum option is false.  (When that option 
is true, getPicture() results in "Error capturing image".)
   
   ## Information
   I'm using a Pixel 2 XL emulator from the latest Android Studio for Linux, 
targeting Android 7.1.1 (API 25).  (Other than that, I don't use Studio; I just 
use the cordova command line.)  I haven't tried this on a physical phone, nor 
have I tried it on iOS.
   
   ### Command or Code
   Here's the relevant code:
   `    let options= {quality: 100,
                     destinationType: Camera.DestinationType.FILE_URI,
                     sourceType: Camera.PictureSourceType.CAMERA,
                     encodingType: Camera.EncodingType.PNG,
                     targetWidth: 600,
                     targetHeight: 600,
                     mediaType: Camera.MediaType.PICTURE,
                     correctOrientation: true,
                     saveToPhotoAlbum: false
                    } ;
   
       let photo_url= await new Promise((resolve, reject) =>
           navigator.camera.getPicture(function(result) {
                   alert('in getPicture success, 
result=['+JSON.stringify(result)+']') ;
                   resolve(result) ;
               }, function(err) {
                   alert('in getPicture error, err=['+JSON.stringify(err)+']') ;
                   reject(err) ;
               }, options)) ;
   
       let img_file_entry= await url_to_entry(photo_url) ;
       let img_data= await read_file_binary(img_file_entry) ;
   `
   
   ... and here are those two routines from a short file IO library:
   `async function read_file_binary(file_entry) {
       // file_entry.fullPath looks correct at this point
       return new Promise((resolve, reject) => {
           file_entry.file(file => {
               let reader = new FileReader() ;
               reader.onloadend= function(e) {
                   resolve(this.result) ;      // this.result is now an empty 
object {}
               } ;
               reader.readAsArrayBuffer(file) ;
           }) ;
       }) ;
   }
   
   function url_to_entry(url) {
       return new Promise((resolve, reject) => resolveLocalFileSystemURL(url, 
resolve, reject)) ;
   }
   `
   
   ### Environment, Platform, Device
   ### Version information
   I am using:
   Cordova 10.0.0
   cordova-plugin-camera 5.0.0
   cordova-plugin-file 6.0.2
   
   Linux (openSuSE LEAP 15.1), kernel 4.12.14
   Android Studio 4.0.1
   
   ## Checklist
   <!-- Please check the boxes by putting an `x` in the `[ ]` like so: `[x]` -->
   
   - [x] I searched for already existing GitHub issues about this
   - [ ] I updated all Cordova tooling to their most recent version
   - [x] I included all the necessary information above
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to