- 发布:2024-01-10 10:39
- 更新:2024-01-10 10:44
- 阅读:339
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: window10
HBuilderX类型: 正式
HBuilderX版本号: 3.97
手机系统: 全部
页面类型: vue
vue版本: vue3
打包方式: 云端
项目创建方式: HBuilderX
测试过的手机:
示例代码:
uni.chooseImage({
count: 1, //默认9
sizeType: ['original', 'compressed'],
sourceType: ['album'],
success: async function (e: any) {
let tempArr = []
console.log(e,"ee");
try{
await handleUpload(e.tempFiles[0])
}catch(e){
console.log(e,"error")
}
console.log(e.tempFiles[0]);
console.log(upload.value.url,"结果")
// if (responce.code) { showTips("")
// } else {
// contUrl.value = responce
// tempArr.push(responce)
// let imgIds: any = await uploadDeal(tempArr)
// formData.value.bill.billImgId = imgIds.data.join()
// }
},
fail: () => {
showTips("退出相册")
}
});
// 控制台
{"tempFilePaths":
["file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp/compressed/1704852711221_wx_camera_1704605049210.jpg"],"tempFiles":[{"path":"file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp/compressed/1704852711221_wx_camera_1704605049210.jpg","size":141623}],"errMsg":"chooseImage:ok"} , ee1
uni.chooseImage({
count: 1, //默认9
sizeType: ['original', 'compressed'],
sourceType: ['album'],
success: async function (e: any) {
let tempArr = []
console.log(e,"ee");
try{
await handleUpload(e.tempFiles[0])
}catch(e){
console.log(e,"error")
}
console.log(e.tempFiles[0]);
console.log(upload.value.url,"结果")
// if (responce.code) { showTips("")
// } else {
// contUrl.value = responce
// tempArr.push(responce)
// let imgIds: any = await uploadDeal(tempArr)
// formData.value.bill.billImgId = imgIds.data.join()
// }
},
fail: () => {
showTips("退出相册")
}
});
// 控制台
{"tempFilePaths":
["file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp/compressed/1704852711221_wx_camera_1704605049210.jpg"],"tempFiles":[{"path":"file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp/compressed/1704852711221_wx_camera_1704605049210.jpg","size":141623}],"errMsg":"chooseImage:ok"} , ee1
操作步骤:
执行uni.chooseimage API,看返回的文件即可
执行uni.chooseimage API,看返回的文件即可
预期结果:
返回file对象
返回file对象
实际结果:
"tempFiles":[{"path":"file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp/compressed/1704852711221_wx_camera_1704605049210.jpg","size":141623}],
"tempFiles":[{"path":"file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/uniapp_temp/compressed/1704852711221_wx_camera_1704605049210.jpg","size":141623}],
bug描述:
uni.chooseImage 选择图片API,app端返回的不是File对象,是普通object对象。导致无法上传图片到阿里云oss
1***@163.com (作者)
感谢兄弟!新年快乐
2024-01-10 11:47