游码笔记
游码笔记
  • 发布:2022-05-17 17:17
  • 更新:2022-05-17 17:21
  • 阅读:784

【报Bug】支付宝小程序在ios是正常的,在 安卓手机上使用uni.downloadFile下载图片,返回的图片链接是失效的,是一个空白图片,这是怎么回事?

分类:uni-app

产品分类: uniapp/小程序/阿里

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: window10

HBuilderX类型: 正式

HBuilderX版本号: 3.4.7

第三方开发者工具版本号: 2.3.4

基础库版本号: 2.0

项目创建方式: HBuilderX

示例代码:

    header['tercode'] = store.state.uuid  
    header['version'] = '1'  
    header['authorization-token'] = store.state.token  
uni.downloadFile({  
            url: completeUrl,  
            header: header,  
            success: (res) => {  
                if (res.tempFilePath) {  
                    uni.getImageInfo({  //todo:出现错误 error:18,code:获取图片信息失败  
                            src: res.tempFilePath,  
                            success: function(res2) {  
                                uni.showToast({  
                                    title: res2.path  
                                })  
                                uni.saveFile({  
                                    tempFilePath: res2  
                                        .path,  
                                    success: function(  
                                        res3) {  
                                        let fjImagePath = res3.savedFilePath  
                                    }  
                                })  
                            },  
                        })  
                } else reject(new ApiError(-1, "下载失败:" + JSON.stringify(res)));  
            },  
            fail(err) {  
                reject(new ApiError(-1, "下载失败:" + err));  
            },  

            complete() {  
                uni.hideLoading();  
            }  
        })```

操作步骤:

    header['tercode'] = store.state.uuid  
    header['version'] = '1'  
    header['authorization-token'] = store.state.token  
uni.downloadFile({  
            url: completeUrl,  
            header: header,  
            success: (res) => {  
                if (res.tempFilePath) {  
                    uni.getImageInfo({  //todo:出现错误 error:18,code:获取图片信息失败  
                            src: res.tempFilePath,  
                            success: function(res2) {  
                                uni.showToast({  
                                    title: res2.path  
                                })  
                                uni.saveFile({  
                                    tempFilePath: res2  
                                        .path,  
                                    success: function(  
                                        res3) {  
                                        let fjImagePath = res3.savedFilePath  
                                    }  
                                })  
                            },  
                        })  
                } else reject(new ApiError(-1, "下载失败:" + JSON.stringify(res)));  
            },  
            fail(err) {  
                reject(new ApiError(-1, "下载失败:" + err));  
            },  

            complete() {  
                uni.hideLoading();  
            }  
        })```

预期结果:

可以查看图片信息

实际结果:

getImageInfot出现错误 error:18,code:获取图片信息失败

bug描述:

【报Bug】支付宝小程序在ios是正常的,在 安卓手机上使用uni.downloadFile下载图片,返回的图片链接是失效的,是一个空白图片,这是怎么回事?使用uni.getImageInfo就一直显示错误 error:18,code:获取图片信息失败

2022-05-17 17:17 负责人:无 分享
已邀请:
FullStack

FullStack - 【插件开发】【专治疑难杂症】【ios上架、马甲包、白包、过审、已成功上架过几百个】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=22130】【非诚勿扰】QQ:543610866

换个图片地址,试试,https://img-cdn-tc.dcloud.net.cn/uploads/avatar/000/73/57/99_avatar_mid.jpg?v=1652751980

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