[英]Cordova Plugins Photo Library Plugin: Get downloaded picture file_uri path
I am using Cordova Plugins Photo Library Plugin to download picture from server or internet. 我正在使用Cordova插件照片库插件从服务器或Internet下载图片。 I successfully downloaded picture from internet and server.
我成功地从互联网和服务器下载了图片。 However, I fail to get the path of picture.
但是,我无法获得图片的路径。 I need the file_uri path so that I can display the picture by showing the file_uri path.
我需要file_uri路径,以便可以通过显示file_uri路径来显示图片。
The following is my code. 以下是我的代码。
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);
});
You can get the path to the photo using the photoURL
attribute of libraryItem
. 您可以使用
libraryItem
的photoURL
属性获取照片的路径。
Here is the code - 这是代码-
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);
});
Refer Displaying photos Section of cordova-plugin-photo-library
for other attributes of libraryItem
. 有关
libraryItem
其他属性,请参阅cordova-plugin-photo-library
的libraryItem
photos部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.