-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
camera.getPicture() with FILE_URI destination returns invalid/unexpected image URI #783
Comments
I have the same issue. Did you found some solution? |
I don't think so :(
|
Same issue |
For me |
@cmarian5 do you still receive the image url like: file:///data/user/0/package.name/cache/1645202153127.jpg I have that preference enabled in my config.xml, added & removed Android etc. and still get the same issue |
With that preference in config.xml I get it like this In this case the image is displayed correctly. Also in your case should work. |
This issue is related to the scoped storage of Android 11. (A) use DATA_URL && low targetHeight & targetWidth values (<3000) The latest entry-level smartphones have large pixels, so an "out of memory" error occurs during conversion to base64.
(B) Save the image to photoalbum --> read the image
Although "cordova-pluggin-camera" can not access the 'cache' folder, but it can write it on photoalbum folder. cf) src/android/CameraLauncher.java line 226 : getCacheDir() --> FAIL
line 532 : galleryUri.toString() --> SUCCESS
This FILE URI can be read by the following code.
|
if (this.targetHeight == -1 && this.targetWidth == -1 && && getMimetypeForEncodingType().equalsIgnoreCase(mimeTypeOfGalleryFile)) 把这个判断去掉 强制走if条件 |
Cordova Android 10.0.0 Released! - Apache Cordova As described in the Release document, to keep the previous behavior, add the following to config.xml
URLs must be converted using cordova-plugin-file in order to be accessed correctly by WebViewAssetLoader.
I think you should modify README.md. |
so I have to call window.resolveLocalFileSystemURL(imageUri, (fileEntry) => { |
same issue here. Need a content URI to get the proper filename. Is there a way
|
I'm facing same issue with Android 13 and
function onPhotoURISuccess(imgUri) {
console.log(imgUri); // on Android 13 it's a uri without file:// and resolveLocalFileSystemURL will fail.
// in case of resolveLocalFileSystemURL fail I'll try to manage imgUri as imgData and store Base64 encoded data to a new File.
window.resolveLocalFileSystemURL(imgUri, function success(fileEntry) {
console.log(JSON.stringify(fileEntry));
console.log("got file: " + fileEntry.fullPath);
return fileEntry;
}, function (error) {
console.log(error.code); // on Android 13 it's Error Code 5
var tmp = createNewFileEntry(imgUri);
return tmp;
});
}
debugging the see also #866 |
same issue |
With #902 which will streamline the returned data. It should make it's way to the next major 8.x release. Most common uris will be If using If |
Bug Report
Problem
What is expected to happen?
camera.getPicture() to return a valid file_URI in the form of
content://media/external/images/media/2
when Camera.DestinationType = FILE_URIWhat does actually happen?
the returned value is something like:
file///data/user/0/com.tld.appname/cache/1642011143203.jpg
and this seems to be an unreacheable url for the webview (can not render the picture). Moreover, searching through the filesystem i can't see such a file. There is no problems when the Camera.DestinationType = DATA_URL, however it is undesired due to possible memory problemsInformation
Command or Code
navigator.camera.getPicture(onSuccess, onFail, { quality: 50, destinationType: Camera.DestinationType.FILE_URI });
Environment, Platform, Device
Developing on Windows 10, the result is with Android 7.0 phone
Version information
[email protected]
[email protected]
[email protected]
Android SDK Platform 11.0 / API Level 30
Gradle 7.3.3
Checklist
I searched for existing GitHub issues
I updated all Cordova tooling to most recent version
I included all the necessary information above
The text was updated successfully, but these errors were encountered: