You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2022/01/11 21:43:27 UTC
[GitHub] [cordova-android] AKempente commented on issue #1053: android@9.0.0 and cordova cli 10.0.0 cdvfile://localhost net::ERR_UNKNOWN_URL_SCHEME
AKempente commented on issue #1053:
URL: https://github.com/apache/cordova-android/issues/1053#issuecomment-1010385567
After trying many of the solutions on this topic, i just want to share how i solved this problem without adding additional configuration meta tags in the header or config.xml in my case i want to take a picture, preview and upload it to server.
the important thing in the following code sample is "url: window.URL.createObjectURL(imgBlob),"
and now i can display the image taken by setting image DOM src.
I hope this helps someone out there ;)
resolveFile (imageURI) {
return new Promise((resolve, reject) => {
window.resolveLocalFileSystemURL(imageURI, (fileEntry) => {
fileEntry.file(file => {
const reader = new FileReader()
reader.onloadend = () => {
const imgBlob = new Blob([reader.result], {
type: file.type
})
const resData = {
name: fileEntry.name,
// url: fileEntry.toInternalURL(), // NO LONGER WORKS
url: window.URL.createObjectURL(imgBlob),
blob: imgBlob,
fileEntry: fileEntry
}
window.URL.revokeObjectURL(imgBlob)
resolve(resData)
}
reader.readAsArrayBuffer(file)
}, (error) => {
console.log(error)
reject(error)
})
})
})
},
--
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.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org