背景:由于部分用户安卓手机出现使用uni.chooseImage 图片排序与相册排序不一致问题,现改用uni.chooseMedia进行打开相册选择图片上传,但是出现新的问题:由于业务需要上传图片不能超出指定大小,所以进行压缩,发现耗时比使用uni.chooseImage多不少,经查发现使用uni.chooseMedia选择的图片没有进行过压缩。
代码配置如下:
uni.chooseMedia({
count: 999,
mediaType: ['image'],
sourceType: ['album'],
sizeType: ['compressed'],
success(res) {
console.log(res.tempFiles)
}
})
打印数据如下:
[
{
"fileType": "image",
"tempFilePath": "file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/temp/uni-media/1*****.jpg",
"size": 3038367
},
{
"fileType": "image",
"tempFilePath": "file:///storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/temp/uni-media/1**.jpg",
"size": 3626115
}
]
0 个回复