1***@qq.com
1***@qq.com
  • 发布:2021-03-12 16:56
  • 更新:2022-01-07 17:32
  • 阅读:1361

liver-pusher快照snapshot生成的图片无法通过uni.saveFile 进行临时文件

分类:uni-app

通过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

2021-03-12 16:56 负责人:无 分享
已邀请:
3***@qq.com

3***@qq.com

文件路径前加上 file://

1***@qq.com

1***@qq.com - 海底月是天上月~

解决了吗

该问题目前已经被锁定, 无法添加新回复