我是NativeScript的新手。
我使用nativescript-plugin-firebase下载用户的照片并将其保存到/data/user/0/{APP_ID}/files/telerik-logo-downloaded.png中。
Firebase存储本地API示例:
var fs = require("tns-core-modules/file-system");
// let's first determine where we'll create the file using the 'file- system' module
var documents = fs.knownFolders.documents();
var logoPath = documents.path + "/telerik-logo-downloaded.png";
// this will create or overwrite a local file in the app's documents folder
var localLogoFile = documents.getFile("telerik-logo-downloaded.png");
// now download the file with either of the options below:
firebase.storage.downloadFile({
bucket: 'gs://n-plugin-test.appspot.com',
remoteFullPath: 'uploads/images/telerik-logo-uploaded.png',
localFile: fs.File.fromPath(logoPath),
localFullPath: logoPath
}).then(
function (uploadedFile) {
console.log("File downloaded to the requested location");
},
function (error) {
console.log("File download error: " + error);
}
);当发生更改(例如,用户上传一张新照片)时,我将使用Firebase Storage 下载照片并覆盖现有的照片。
var localLogoFile = documents.getFile("telerik-logo-downloaded.png");如果本地文件存在,上面的代码应该覆盖它。
结果,新的照片将显示在iOS上,而不是安卓。对于Android来说,这仍然是老照片。
有人能帮忙吗?谢谢~
发布于 2018-11-09 13:25:12
我想您的问题在于加载imageSource的方式。
它应该已经覆盖了文件,尝试如下
img.src = imageSource.fromFile(logoPath)而不是
img.src = logoPath希望能帮上忙!干杯!
发布于 2018-11-09 14:16:52
如果再次使用相同的url,Android图像将不会被刷新。尝试将图像源设置为null,然后再将其设置为您的路径。
https://stackoverflow.com/questions/53224334
复制相似问题