通过snapshot能成功去到图片路径,但是无法通过saveFile来进行保存,会出现文件路径不存在
/**
* 快照
*/
snapshot() {
console.log("快照")
this.context.snapshot({
success: (e) => {
console.log(e);
console.log("e.message.tempImagePath", e.message.tempImagePath);
// uni.setStorageSync('faceImg', e.message.tempImagePath);
this.img = e.message.tempImagePath;
this.img = this.img.substr(1);
console.log("this.img", this.img);
uni.saveFile({
tempFilePath: this.img,
success: function(res) {
var savedFilePath = res.savedFilePath;
console.log("savedFilePath", savedFilePath);
},
fail: (err) => {
console.log("err", err);
}
});
console.log("livePusher.snapshot:" + JSON.stringify(e));
},
fail: (err) => {
this.result = err;
}
});
}
// 日志打印
16:47:00.563 快照 at pages/attandent/clock_in/photo/index.nvue:129
16:47:00.645 [Object] {"message":{"height":900,"width":1080,"tempImagePath":"/storage/emulated/0/Android/data/io.dcloud.HBuilder...} at pages/attandent/clock_in/photo/index.nvue:132
16:47:00.666 e.message.tempImagePath, /storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/snapshot/snapshot_1615538819755.jpg at pages/attandent/clock_in/photo/index.nvue:133
16:47:00.689 this.img, storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/snapshot/snapshot_1615538819755.jpg at pages/attandent/clock_in/photo/index.nvue:137
16:47:00.708 livePusher.snapshot:{"message":{"height":900,"width":1080,"tempImagePath":"/storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/snapshot/snapshot_1615538819755.jpg"},"errMsg":"snapshot:ok"} at pages/attandent/clock_in/photo/index.nvue:148
16:47:00.729 err, [Object] {"errMsg":"saveFile:fail 路径不存在","errCode":14,"code":14} at pages/attandent/clock_in/photo/index.nvue:145
2 个回复
3***@qq.com
文件路径前加上 file://
1***@qq.com - 海底月是天上月~
解决了吗
1***@qq.com
楼上正解
2022-01-11 09:55