使用以下程序获取用户微信头像并上传到云存储里,照片特别小。只有几KB。导致后面生成的照片特别模糊,清晰度特别低?请问该如何解决呢?烦请回答!谢谢
async onChooseAvatar(e) {
let avatarUrl = e.detail.avatarUrl
// console.log('上传前',avatarUrl)
//const avatarTemp = await this.getTempFile(avatarUrl)
const url = await this.uploadFile(avatarUrl, '用户头像' + this.formatDate() + '.jpg')
this.avatarImage = url;
let userInfo = {
avatarImage: this.avatarImage
}
uni.setStorageSync('user_info', userInfo);
this.init();
this.postUserInfo('微信用户', this.avatarImage, 'createImages');
},
getTempFile(str) {
let that = this
var manager = wx.getFileSystemManager()
return new Promise((resolve,reject) => {
manager.readFile({
filePath: str,
success(res) {
resolve(res.data)
}
})
})
},
async uploadFile(filePath, fileName) {
const result = await uniCloud.uploadFile({
filePath: filePath,
cloudPath: fileName
});
return result.fileID
},
1 个回复
NiceUI前端 - 全栈开发
同问