アプリケーションの作成には、telek アプリ ビルダー プラットフォームを使用しました。ダウンロード画像機能を作成しました。この機能は Android デバイスでは機能しますが、iOS では機能しません。なぜ機能しないのかわかりません。
ユーザーが Android デバイスのアプリケーションを使用して画像をダウンロードすると、cordova ファイルシステムがディレクトリを作成し、そのディレクトリに画像を保存し、画像もギャラリーに表示されました。ユーザーが iOS で同じアクションを実行すると、ディレクトリは作成されず、画像はギャラリーに表示されません。この画像を保存する場所が見つかりません。
ダウンロードした画像を iOS ギャラリーに保存する方法を教えてください。
私のコードは以下です
function onDeviceReady() {
var that = this,
App = new downloadApp(),
fileName = "sample.png",
uri = encodeURI("http://www.telerik.com/sfimages/default-source/logos/app_builder.png"),
folderName = "test";
navigator.splashscreen.hide();
App.run(uri, fileName, folderName);
}
downloadApp.prototype = {
run: function (uri, fileName, folderName) {
var that = this,
filePath = "";
document.getElementById("download").addEventListener("click", function () {
that.getFilesystem(
function (fileSystem) {
console.log(fileSystem);
that.getFolder(fileSystem, folderName, function (folder) {
filePath = folder.toURL() + "\/" + fileName;
console.log(filePath);
that.transferFile(uri, filePath)
}, function () {
console.log("failed to get folder");
});
},
function () {
console.log("failed to get filesystem");
}
);
});
},
getFilesystem: function (success, fail) {
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, success, fail);
},
getFolder: function (fileSystem, folderName, success, fail) {
fileSystem.root.getDirectory(folderName, { create: true, exclusive: false }, success, fail)
},
transferFile: function (uri, filePath) {
var transfer = new FileTransfer();
transfer.download(
uri,
filePath,
function (entry) {
var targetPath = entry.toURL();
},
function (error) {
console.log(error)
}
);
},