1***@qq.com
1***@qq.com
  • 发布:2023-02-23 15:10
  • 更新:2023-08-07 14:24
  • 阅读:514

uploadFile:fail Error: getaddrinfo ENOTFOUND file-uninjwtyrm-mp.......

分类:uniCloud

开发者您好!我遇到一个问题,域名配置好了,但是出现的错误提示如下:WAServiceMainContext.js?t=wechat&s=1677134885751&v=2.30.2:1 Error: uploadFile:fail Error: getaddrinfo ENOTFOUND file-uninjwtyrm-mp-aecb2fa6-39c1-4b92-b8ce-9ef005486527.oss-cn-zhangjiakou.aliyuncs.com。


烦请解答!谢谢!
程序源码 如下:

<button class="avatar-wrapper action-btn btn-margin" open-type="chooseAvatar"   
                    @chooseavatar="onChooseAvatar">  
                      选择头像  
                    </button>   
                    <button class="action-btn btn-primary btn-margin" @click="shareFc()">保存头像</button>  
                    <button open-type="share" class="action-btn share-btn">发给朋友</button>  

methods: {  
        async onChooseAvatar(e) {  
          let avatarUrl = e.detail.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  
        },  
}
2023-02-23 15:10 负责人:无 分享
已邀请:
董路飞

董路飞 - 搜索小程序麻丝和 App 麻丝

get addrinfo NOT FOUND 获取地址没有发现。

你把上传地址也写到 request 合法域名 白名单里。

uniCloud.uploadFile 没有 filePath 这个选项配置,是 fileContent

DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

有没有开代理或者vpn,有没有修改设备的dns,换个网络能上传吗

1***@qq.com
1***@qq.com

1***@qq.com

摸摸

要回复问题请先登录注册