我有以下代码保存图片从网址到Download
文件夹
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应用程序中不可见。当我搜索它时,我发现我们应该对该文件运行一些媒体扫描程序。
如何运行媒体扫描程序?有什么api吗?
发布于 2014-12-03 02:29:15
我终于找到了答案。运行介质扫描程序内部文件下载成功回调。
// Run media scanner to make it visible in Gallery app.
cordova.exec(null, null, 'ScanMedia', 'mediaScanner', [result.nativeURL]);
https://stackoverflow.com/questions/27255757
复制相似问题