は、このアプリhereに基づく例です:あなたは、例えばImageSourceは用fromUrl方法でそれを呼び出すことができるように
活字体
export function saveFile(res: ImageSource) {
fileName = "some-image-name" + ".jpeg";
var folderPath;
if (application.android) {
var androidDownloadsPath = android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DOWNLOADS).toString();
folderPath = fileSystem.path.join(androidDownloadsPath, "MyImages");
}
var folder = fileSystem.Folder.fromPath(folderPath);
var path = fileSystem.path.join(folderPath, fileName);
var exists = fileSystem.File.exists(path);
if (!exists) {
var saved = res.saveToFile(path, enums.ImageFormat.jpeg);
}
}
メソッドは、パラメータとしてImageSourceはを受け入れます
import * as imageSource from "image-source";
imageSource.fromUrl(IMAGE_URL_HERE)
.then(res => {
saveFile(res); //
})
あなたは、Android `nativescript-downloadmanager`のために使用することができ
は - https://www.npmjs.com/package/nativescript-downloadmanager –