如何在cordova应用程序中显示来自iOS的`DestinationType = NATIVE_URI`图像

时间:2016-10-04 20:03:00

标签: ios cordova cordova-plugins

我正在查看cordova.plugin.camera,它现在提供DestinationType=NATIVE_URI设置,但我不确定我是如何在cordova App中使用它的。

  

这是一个来自How to access image from native URI (assets-library) in Cordova for iOS

的示例
resolveLocalFileSystemURL('assets-library://asset/asset.JPG?id=711B4C9D-97D6-455A-BC43-C73059A5C3E8&ext=JPG', function(fileEntry) {
    fileEntry.file(function(file) {
        var reader = new FileReader();
        reader.onloadend = function(event) {
            console.log(event.target.result.byteLength);
        };
        console.log('Reading file: ' + file.name);
        reader.readAsArrayBuffer(file);
    });
});

我假设我将使用cordova.plugin.file来读取NATIVE_URI引用的文件,例如'assets-library://asset/asset.JPG?id=711B4C9D-97D6-455A-BC43-C73059A5C3E8&ext=JPG'

但是如何在cordova应用程序中显示JPG文件为IMG.src?像这样:

//<img ng-src="{{myImageSrc}}">
myImageSrc = 'assets-library://asset/asset.JPG?id=711B4C9D-97D6-455A-BC43-C73059A5C3E8&ext=JPG'
myImageSrc = 'cdvfile://localhost/asset/asset.JPG?id=711B4C9D-97D6-455A-BC43-C73059A5C3E8&ext=JPG'
// or use cordova.plugin.file to write image to 
// cordova.file.applicationStorageDirectory, then
myImageSrc = 'file:////var/mobile/Applications/<UUID>/Library/...'

0 个答案:

没有答案