saveimagefile里没指定filePath
saveimagefile2里指定了filePath
结果:在getsavefiles里能查到saveimagefile保存的文件,查不到saveimagefile2保存的文件。
saveimagefile(e){
let that = this;
var fsm = wx.getFileSystemManager();
fsm.saveFile({
tempFilePath: that.data.outpath,
success(rs){
that.setData({
savefilepath: rs.savedFilePath
});
}
});
},
saveimagefile2(e){
let that = this;
let userdatapath = wx.env.USER_DATA_PATH;
console.log("userdatapath=",userdatapath);
let savepath = userdatapath + "/123.jpg";
var fsm = wx.getFileSystemManager();
fsm.saveFile({
tempFilePath: that.data.outpath,
filePath: savepath,
success(rs){
that.setData({
savefilepath: rs.savedFilePath
});
}
});
},
getsavefiles(e){
let that = this;
var fsm = wx.getFileSystemManager();
fsm.getSavedFileList({
success(res){
let flist = res.fileList;
var str = "";
for(var i=0;i<flist.length;i++){
str = str+ flist[i].filePath+"\n";
}
console.log(str);
that.setData({themsg: str});
}
});
},
仔细看了api文档,原来getSaveFiles返回的是本地缓存文件列表,而saveFile时指定了filePath的,属于本地文件,不返回了。