![](/img/trans.png)
[英]IONIC camera plugin FILE_URI returning different file path format based on selected file type (video/picture)
[英]Cordova Plugins Photo Library Plugin: Get downloaded picture file_uri path
我正在使用Cordova插件照片库插件从服务器或Internet下载图片。 我成功地从互联网和服务器下载了图片。 但是,我无法获得图片的路径。 我需要file_uri路径,以便可以通过显示file_uri路径来显示图片。
以下是我的代码。
var url = 'https://images-cdn.9gag.com/photo/am9znpv_700b.jpg';
var album = 'DRDMChat';
cordova.plugins.photoLibrary.saveImage(url, album,
function (libraryItem) {
var ImagePath = libraryItem.cdvphotolibrary
alert(libraryItem.cdvphotolibrary);
}, function (err) {
alert(err);
});
您可以使用libraryItem
的photoURL
属性获取照片的路径。
这是代码-
var url = 'https://images-cdn.9gag.com/photo/am9znpv_700b.jpg';
var album = 'DRDMChat';
cordova.plugins.photoLibrary.saveImage(url, album,
function (libraryItem) {
//log or alert the below attributes
console.log(libraryItem.id); // ID of the photo
console.log(libraryItem.photoURL); // Cross-platform access to photo
console.log(libraryItem.thumbnailURL);// Cross-platform access to thumbnail
console.log(libraryItem.fileName);
var ImagePath = libraryItem.photoURL //Photo URL Access
alert(libraryItem.photoURL);
}, function (err) {
alert(err);
});
有关libraryItem
其他属性,请参阅cordova-plugin-photo-library
的libraryItem
photos部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.