All,
I’m trying to get the file size (i.e. not the dimensions, but the actual file size in disk) of a photo using PhoneGap/Cordova 2. So far, the only way I can figure it out is through base64 conversion, then basic arithmetic on the bytes of the b64 string. However, I was wondering if there is a more elegant way to get file size. TIA.
clarification: it must work on iOS 5 and Android 2.3.
Yeah, if you have the URL to the image from the Camera.getPicture command you pass it to the window.resolveLocalFileSystemURL command who’s success callback is called with a FileEntry object. Then you call the “file” method of FileEntry which calls the success callback with a File object then you can look at the size property of the File object.
Something like….
that should work but I just wrote the code off the top of my head.