I am using the PhoneGap Camera API to take a picture and store it using destinationType.FILE_URI
. This portion is working. I can subsequently take the path provided and set it as the src of an HTML image, and the image appears.
Later in the code, I want to grab the image, convert it to base64encoded data, and transmit it to the server. This is where the problem is.
I am getting {"code" : 5}
(which, according to this, means it's an invalid URI) in my fail callback when using:
fileSystem.root.getFile("content://media/external/images/media/4292", null, gotFileEntry, fail);
I don't understand why I can set an img.src
, but phoneGap can't use the same URI to find the file?
It is because the Android OS has a URI handler for the content://
protocol. The File API does not. However, there is a way for you to convert a content://
type URI into a FileEntry
. Use:
window.resolveLocalFileSystemURI("content://media/external/images/media/4292", win, fail);
and the success callback win
will be called with a FileEntry
for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With