下载后图库不显示图像? [英] Gallery does not show the image after download?
本文介绍了下载后图库不显示图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码将图片从网址保存到下载
文件夹
I have following code to save image from url to Download
folder
var filename = url.replace(/^.*[\\\/]/, '');
var filePath = cordova.file.externalRootDirectory + 'Download/' + filename;
$cordovaFile.downloadFile(url, filePath, true, {})
.then(function(result) {
// Success!
$cordovaToast.showShortCenter('This picture has been saved!');
}, function(err) {
$ionicPopup.alert({ title: 'Error!', template: angular.toJson(err) });
});
成功保存图像。我可以浏览SD卡中的文件。但它在Gallery应用程序中不可见。当我搜索它时,我发现我们应该在该文件上运行一些媒体扫描程序。
It saves the image successfully. I can explore the file in the SD card. But it is not visible in Gallery app. When i search for it, i found that we should run some media scanner on that file.
我如何运行媒体扫描程序?有没有api?
How do i run media scanner? is there any api?
推荐答案
最后我找到了答案。在文件下载成功回调中运行媒体扫描程序。
Finally i found an answer. Run the media Scanner inside file download success callback.
// Run media scanner to make it visible in Gallery app.
cordova.exec(null, null, 'ScanMedia', 'mediaScanner', [result.nativeURL]);
这篇关于下载后图库不显示图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文