Sam888
Sam888
  • 发布:2025-03-15 11:25
  • 更新:2025-03-15 11:25
  • 阅读:127

【报Bug】uni.saveImageToPhotosAlbum()在鸿蒙next中保存无效

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

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

HBuilderX类型: 正式

HBuilderX版本号: 4.56

手机系统: HarmonyOS NEXT

手机系统版本号: HarmonyOS NEXT Developer Preview

手机厂商: 华为

手机机型: mate60pro

页面类型: vue

vue版本: vue3

打包方式: 离线

项目创建方式: HBuilderX

示例代码:
// #ifdef APP-HARMONY  
                //利用plus完成保存到相册    
                let that = this  
                uni.downloadFile({  
                    url: this.wximage,  
                    success: function(res) {  
                        ///data/storage/el2/base/temp/HBuilder/download/1742005312684  
                        console.log("下载成功",res);   

                        uni.saveImageToPhotosAlbum({  
                            filePath: res.tempFilePath,  
                            success(res) {  
                                // console.log(res);  
                                uni.showToast({  
                                    title: '保存成功!',  
                                    icon: 'none'  
                                })  
                            },  
                            fail(res) {  
                                console.log(res);  
                                uni.showToast({  
                                    title: '保存失败!',  
                                    icon: 'none'  
                                })  
                            },  
                        });  
                    },  
                    fail: function() {  
                        console.log('fail')  
                    }  
                })  
                // #endif

操作步骤:
// #ifdef APP-HARMONY  
                //利用plus完成保存到相册    
                let that = this  
                uni.downloadFile({  
                    url: this.wximage,  
                    success: function(res) {  
                        ///data/storage/el2/base/temp/HBuilder/download/1742005312684  
                        console.log("下载成功",res);///data/storage/el2/base/temp/HBuilder/canvas/1742005566471_3.png  
                        that.getImageInfo(res.tempFilePath).then(res =>{  
                            console.log("获取图片信息",res);  
                        });  
                        uni.saveImageToPhotosAlbum({  
                            filePath: res.tempFilePath,  
                            success(res) {  
                                // console.log(res);  
                                uni.showToast({  
                                    title: '保存成功!',  
                                    icon: 'none'  
                                })  
                            },  
                            fail(res) {  
                                console.log(res);  
                                uni.showToast({  
                                    title: '保存失败!',  
                                    icon: 'none'  
                                })  
                            },  
                        });  
                    },  
                    fail: function() {  
                        console.log('fail')  
                    }  
                })  
                // #endif

预期结果:

保存成功

实际结果:

保存失败报错

bug描述:

saveImageToPhotosAlbum:fail save error, code: -2004

2025-03-15 11:25 负责人:无 分享
已邀请:

要回复问题请先登录注册