【发布时间】:2015-08-24 10:41:57
【问题描述】:
我有这段代码可以从 URL 下载图像并保存在我的手机设备中,但问题是它没有显示在手机设备的图片库中,而是显示在文件存储目录中。所以,我想让它出现在图片库中。
$scope.downloadImage = function(images) {
var imageName = angular.fromJson(images);
$scope.$applyAsync(function() {
$scope.indexchosen === undefined ? $scope.indexchosen = 0 : $scope.indexchosen;
console.log($scope.indexchosen)
index = $scope.indexchosen;
imageToDownload = imageName[index].filename;
})
$scope.$applyAsync(function() {
window.requestFileSystem(window.LocalFileSystem.PERSISTENT, 0, onSuccess, onError);
});
function onSuccess(fileSystem) {
var directoryEntry = fileSystem.root;
countImage+=1;
var name = countImage + '-' + imageToDownload.split('/').pop();
var imageUrl = encodeURI(decodeURIComponent(AppSettings.baseApiUrl + imageToDownload));
var fp = fileSystem.root.toURL();
var filepath = fp + '/' + name;
console.log(filepath)
var ft = new window.FileTransfer();
var f = ft.download(imageUrl, filepath,
function (entry) {
$cordovaToast.show("Image Saved", "long", "bottom");
},
function (error) {
}
);
}
function onError(error) {
}
}
感谢任何帮助。
【问题讨论】:
标签: android cordova ionic-framework