NativeScript / plugins

@nativescript plugins to help with your developments.
https://docs.nativescript.org/plugins/index.html
Apache License 2.0
190 stars 107 forks source link

Error in downloadBitmap - java.net.MalformedURLException: unknown protocol: content #468

Closed patrickvandasler closed 1 year ago

patrickvandasler commented 1 year ago

I am updating my android app from version 29 to 31, but i am having issues with selecting photos from the gallery. Making a new picture with the camera works fine.

Versions: "@nativescript/core": "^7.1.3", "@nativescript/imagepicker": "^1.0.9",

this.imagePicker
  .authorize()
  .then(() => this.imagePicker.present())
  .then((selection) => {        
    console.log("selection done")
    selection.forEach((selected) => {
      console.log("selected: " + JSON.stringify(selected))
    })
    this.addPhoto(imageAsset);
  })
  .catch((e) => {
    console.log("throwing expcetion")
    // tslint:disable-next-line: no-console
    console.log(e);
  });

After selecting the file i get this url: "content://com.android.providers.media.documents/document/image%3A62"

The addPhoto function puts the imageAsset in a array which is read on the HTML template and put in an image source to show it on screen.

But after I try to put in in the image tag on the HTML the following error occurs: Error in downloadBitmap - java.net.MalformedURLException: unknown protocol: content

Someone has any idea to fix it?

davecoffin commented 1 year ago

In 2.0.0 you can include copyToAppFolder: 'myfolder', which will return a more friendly path.