I'm trying to read as dataurl contact picture

I’m using ionic-native contacts picture plugin and cordova, everything its okay but i need to read photos of contacts as dataurl in order of upload them but i can’t find the way of doing that. Can anyone help me

This isn’t true, FWIW. You can read the photo (or anything else) as an ArrayBuffer and upload that.

but i couldn’t do it, the url in the contact object come as ‘content://com.android.contacts/…’. With webview.convertFileSrc i can show the image but i haven’t found the way of read it as dataurl or ArrayBuffer, can you help me with an example, thank you in advance

Anything you can assign as the src parameter of an img tag should be fetchable with HttpClient. HttpClient can retrieve things as Blobs.

thanks, i will try and let you know

I did it and this was the error:

  1. HttpErrorResponse {headers: HttpHeaders, status: 404, statusText: “OK”, url: “http://localhost/app_content/com.android.contacts/contacts/136/photo”, ok: false, …}

  2. headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ}

  3. status: 404

  4. statusText: “OK”

  5. url: “http://localhost/app_content/com.android.contacts/contacts/136/photo”

  6. ok: false

  7. name: “HttpErrorResponse”

  8. message: “Http failure response for http://localhost/app_content/com.android.contacts/contacts/136/photo: 404 OK”

  9. error: Blob {size: 3692, type: “text/xml”}

  10. proto: HttpResponseBase

Do you have at least version 3.0.0 of the webview plugin? This commit looks highly relevant to your situation.

yes, i have version 4.0.0

Weird, since your situation looks to me more or less identical to this issue, which was marked fixed by that commit. It also surprises me not to see any port 8080 in the URLs you’re getting from the ionic-webview plugin.

That issue is for loading the image, i’m loading the image and showing it in an ion-img. I think like you, if the ion-img can show the image there has to be a way that i can acces to that file and read it. Httpclient is the way but is like not recognize the path to the image