微信小程序,wx.getUserProfile接口将被收回,新的头像获取方式永久保存

发布时间 2023-06-20 17:54:28作者: HelloLLLLL
微信文档:https://developers.weixin.qq.com/miniprogram/dev/framework/
新的获取头像方式:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/userProfile.html
0
这种方式,返回的路径是返回的临时路径,保存在本地。
如果要永久保存的,我的做法是通过 FileSystemManager.readFile
获取文件的base64字符串,然后上传,两个参数:filePath和encoding,
filePath就是选择头像的按钮里事件bindchooseavatar返回的值:e.detail.avatarUrl
encoding:可以是2进制,utf-8,base64,等。
然后就调自己的上传图片接口。