Nativescript 无法将 ImageSource 保存到文件

Nativescript Unable to save ImageSource to file

我正在尝试将 ImageSource 保存到文件中。 我已按照 image-source 部分下的文档中的说明进行操作。 这是我所做的:

let imageSource = new ImageSource();
var fileName = "Test.png";

var knownPath = fs.knownFolders.documents();
var folderPath = fs.path.join(knownPath.path, "Pictures");

var folder = fs.Folder.fromPath(folderPath);
var picturePath = fs.path.join(folderPath, fileName);

let saved  = imageSource.saveToFile(picturePath,"png");

问题是 saved 总是错误的,但我不明白为什么它没有被保存,因为 saveToFile 似乎没有抛出错误。 我做错了什么吗?

正如@HabibKazemi 在评论中指出的那样,imageSource 需要有一些来源。在这种特定情况下,我试图在填充 imageSources 源的承诺之外保存文件。