如何从PhoneGap camera.getPicture获取File对象?

这可能很简单,并且由PhoneGap的“Camera”插件,“File”插件或“File-Transfer”插件中的某些function组合来涵盖。 我了解用户可以select一个文件:

navigator.camera.getPicture(function (fileURI) { // *** need help here *** }, function () // handle errors }, { destinationType: window.Camera.DestinationType.FILE_URI, sourceType: window.Camera.PictureSourceType.PHOTOLIBRARY, mediaType: window.Camera.MediaType.ALLMEDIA }); 

我也可以改变为destinationType: window.Camera.DestinationType.DATA_URL如果destinationType: window.Camera.DestinationType.DATA_URL

我在成功处理程序中的目标是获得一个File对象( https://developer.mozilla.org/en-US/docs/Web/API/File )。

像这样的东西应该这样做。

 navigator.camera.getPicture(function (fileURI) { window.resolveLocalFileSystemURI(fileURI, function( fileEntry){ alert("got image file entry: " + fileEntry.fullPath); }, function(){//error} ); }, function (){ // handle errors }, { destinationType: window.Camera.DestinationType.FILE_URI, sourceType: window.Camera.PictureSourceType.PHOTOLIBRARY, mediaType: window.Camera.MediaType.ALLMEDIA }); 
 window.resolveLocalFileSystemURI(fileURI, function(fileEntry) { /* your code here */ });