Cordova Camera appends query string to the end of FILE_URI in Android


#1

On Android, $cordovaCamera is appending a query string to the end of the FILE_URI in certain circumstances.

When when the sourceType is set to CAMERA and destinationType is set to FILE_URI, it works as expected, returning a path like this: file:///storage/emulated/0/Android/data/com.myappname.myapp/cache/imageName.jpg

However, when the sourceType is set to PHOTOLIBRARY or SAVEDPHOTOALBUM and the destination type is set to FILE_URI, it returns a path with a query string added to the end of the file path, making it impossible to load and use that file with CordovaFileTransfer. The path it returns is like this: file:///storage/emulated/0/Android/data/com.myappname.myapp/cache/image.jpg?12764830288374

The issue is the ?12764830288374 on the end. I understand that query strings are appended to things to avoid browser caching, but we are pulling photos from the phone and each photo name is unique, so caching shouldn’t be an issue. Why does it do this and how can I make it stop?

I realize I could simply strip off everything on the path after the question mark but that seems like a hacky solution. I’d like to know why it is returning the path this way and how to fix it properly.

Note: I have also tried returning it as a NATIVE_URI and the same issues holds true - it appends a question mark with a list of numbers to the end of the file path that prevents cordovaFileTransfer from properly uploading the file.


#2

Hello there!
I’m experiencing the same problem. Wondering if you got solving this
Greetings