简体   繁体   English

Cordova插件照片库插件:获取下载的图片file_uri路径

[英]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 . 您可以使用libraryItemphotoURL属性获取照片的路径。

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-librarylibraryItem photos部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IONIC 相机插件 FILE_URI 根据所选文件类型(视频/图片)返回不同的文件路径格式 - IONIC camera plugin FILE_URI returning different file path format based on selected file type (video/picture) cordova插件摄像头中FILE_URI和NATIVE_URI之间的区别 - Difference between FILE_URI and NATIVE_URI in cordova plugin camera 科尔多瓦相机插件Android将额外的信息附加到FILE_URI的末尾 - Cordova Camera Plugin Android appends extra information to the end of FILE_URI Cordova navigator.camera.getPicture在Android 4.4 KitKat上以意外格式返回FILE_URI - Cordova navigator.camera.getPicture returns FILE_URI in unexpected format on Android 4.4 KitKat from gallery 自定义cordova插件-获取文件路径 - Custom cordova plugin - Get path to file ionic 4 (android) 从图库 (FILE_URI) 获取图像 (OBJECT FILE) 并通过 API 上传 - ionic 4 (android) get image (OBJECT FILE) from gallery (FILE_URI) and upload via API Cordova插件:无法检索图片的路径 - Cordova Plugin: Unable to retrieve path to picture Cordova相机插件:拍照时不显示照片 - Cordova camera plugin: Photo is not displayed when taking a picture 获取从Firebase下载的图片的路径? - Get path from picture downloaded from Firebase? Android相机:拍照后获取照片Uri - Android Camera: Get Picture Uri after the photo is taken
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM