鍍金池/ 問答/Android  HTML/ cordova 用file-transfer插件下載圖片,下載成功但在手機(jī)中找不

cordova 用file-transfer插件下載圖片,下載成功但在手機(jī)中找不到路徑

代碼:

dl:function(){
            var that=this;
            console.log(requestFileSystem)
            window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
            window.requestFileSystem(LocalFileSystem.PERSISTENT, 5*1024*1024, function (fs) {  
                //創(chuàng)建文件  
                console.log(111)
                var url = 'http://www.gongjuji.net/Content/Images/hostoperate1.png';  
                fs.root.getFile('test1.png', { create: true,exclusive: false }, function (fileEntry) {  
                    alert(fileEntry.nativeURL)
                    alert(fileEntry.toURL())
                    download(fileEntry, url);  
                },function(){
                    alert('shibai')
                });  
            },function(){
                alert('shibai')
            })  
            // var ft = new FileTransfer();  
            function download(fileEntry, url) {  
                var ft = new FileTransfer();  
                var fileURL = fileEntry.toURL();  
                // var fileURL = 'storage';  
                //監(jiān)聽下載進(jìn)度  
                ft.onprogress = function (e) {  
                    console.info(e);  
                    if (e.lengthComputable) {  
                        console.log('當(dāng)前進(jìn)度:' + e.loaded / e.total);  
                    }  
                }  
                ft.download(url, fileURL, function (entry) {  
                    console.log('下載成功');  
                    console.info(entry);  
                    console.log('文件位置:' + entry.toURL());  
                    that.url=entry.toURL()
                }, function (err) {  
                    console.log("下載失?。?);  
                }, null, // or, pass false  
                {  
                    //headers: {  
                    //    "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="  
                    //}  
                });  
            }  
        },
      

點(diǎn)擊按鈕調(diào)用dt方法,顯示下載成功,并且文件位置也知道 file:///data/user/0/org.apaxhe.cordova.myApp/files/files/test1.png,但這個(gè)路徑在手機(jī)什么地方,我在文件管理里找到android/data/org.apache.cordova.myApp/files 但里邊文件是空的

回答
編輯回答
瞄小懶

可以貼下代碼不?我也遇到了

2018年1月11日 21:55
編輯回答
哎呦喂

我自己找了一個(gè)方法,裝了一個(gè)file插件,用file插件重新指定了一下下載的路徑,這樣是能找到的

2018年3月31日 04:00