0
필자는 대부분의 코드바 파일 관련 플러그인을 사용해 보았고 마지막으로이 코드를 사용했습니다. 그것은 성공 메시지를주고 있지만 갤러리에 나타나지 않았습니다. 아무도 이것으로 도와 줄 수 있니?ionic app에서 서버의 이미지를 장치 내부 메모리에 저장하는 방법은 무엇입니까?
$scope.download = function download(name, contentType, fileLInk) {
ionic.Platform.ready(function() {
var url = apiServiceBaseUri + fileLInk;
var targetPath = cordova.file.dataDirectory + 'myapp/' + name;
var trustHosts = false;
var options = {
headers: {
'Authorization': tokenType + ' ' + accessToken
}
};
$cordovaFileTransfer.download(url, targetPath, options, trustHosts)
.then(function(result) {
var alertPopup = $ionicPopup.alert({
title: 'File has been downloaded',
});
$ionicListDelegate.closeOptionButtons();
}, function(error) {
$ionicListDelegate.closeOptionButtons();
if (error.http_status == 401) {
$ionicPopup.alert({
title: 'Oops, Session is expired!',
template: 'Looks like your session is expired or you logged in from someother device.'
});
$ionicHistory.clearCache().then(function() {
$state.go('start.login');
});
}
var alertPopup = $ionicPopup.alert({
title: 'Sorry, something went wrong during the request!',
template: error.data.errors[0].message
});
});
});
};
답장을 보내 주셔서 감사합니다 @ ujjwal kaushik. 실제로, 나는 그것을 또한 시도했다. 그러나 어떤 운도. –
그것은 나를 위해 일했습니다. 너를 위해 일하지 않니? –
그렇지 않습니다. 실제로, 나는 그 플러그인을 설치하고이 라인을 성공 호출에 추가했다. $ cordovaFileTransfer.download (URL,있는 TargetPath, 옵션, trustHosts) 그 때는 (기능 (결과) { refreshMedia.refresh (있는 TargetPath) }, 기능 (오류) { // 오류가 간다} }); –