Javascript 错误N代码:";验证/内部错误“;电文:";照片URL太长。”;原型

Javascript 错误N代码:";验证/内部错误“;电文:";照片URL太长。”;原型,javascript,firebase,ionic-framework,firebase-authentication,Javascript,Firebase,Ionic Framework,Firebase Authentication,我正在尝试使用cordova摄像头插件升级firebase配置文件图片。但我有一个错误。有什么想法吗 async openLibrary() { const options: CameraOptions = { quality: 70, destinationType: this.camera.DestinationType.DATA_URL, sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,

我正在尝试使用cordova摄像头插件升级firebase配置文件图片。但我有一个错误。有什么想法吗

   async openLibrary() {
    const options: CameraOptions = {
    quality: 70,
    destinationType: this.camera.DestinationType.DATA_URL,
    sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
    encodingType: this.camera.EncodingType.JPEG,
    saveToPhotoAlbum: false
    };
   return await this.camera.getPicture(options);
  }


  async addPhoto() {
  const libraryImage = await this.openLibrary();
  this.photoCamera = 'data:image/jpeg;base64,' + libraryImage;
  }

   enregisterPseudoo() {

   this.user.updateProfile({
     displayName: this.pseudo,
     photoURL:(this.photoCamera)
     }).then(data => {
     this.navCtrl.push(TabsPage, {
       name: this.pseudo,
       photo:(this.photoCamera),
       });
     });
       }

url太长了,你知道吗?

Firebase身份验证中用户配置文件中的
photoURL
必须是指向现有图像的链接。您正在尝试将图像存储为数据URL,Firebase身份验证无法处理该URL


因此,您必须将数据上载到图像托管服务(例如),然后将生成的URL保存到用户配置文件中。

Firebase身份验证中用户配置文件中的
photoURL
必须是指向现有图像的链接。您正在尝试将图像存储为数据URL,Firebase身份验证无法处理该URL


因此,您必须将数据上载到图像托管服务(例如),然后将生成的URL保存到用户配置文件中。

这对我很有效。将图像存储在firebase存储中,然后获取url

   const libraryImage = await this.openLibrary();
   this.photoCamera = 'data:image/jpeg;base64,' + libraryImage;
     let user = firebase.auth().currentUser;
     this.avatarStgRef = firebase.storage().ref("pictures" + user.uid);
     this.avatarStgRef.putString(this.photoCamera, 'data_url'); 

    this.avatarStgRef.getDownloadURL().then(
    (url)=>{
   this.user.updateProfile({
   displayName: this.pseudo,
  photoURL: url
    }).then(data => {
    this.navCtrl.push(TabsPage, {
    name: this.pseudo,
    photo: url,
     });
      });

})这对我很有效。将图像存储在firebase存储中,然后获取url

   const libraryImage = await this.openLibrary();
   this.photoCamera = 'data:image/jpeg;base64,' + libraryImage;
     let user = firebase.auth().currentUser;
     this.avatarStgRef = firebase.storage().ref("pictures" + user.uid);
     this.avatarStgRef.putString(this.photoCamera, 'data_url'); 

    this.avatarStgRef.getDownloadURL().then(
    (url)=>{
   this.user.updateProfile({
   displayName: this.pseudo,
  photoURL: url
    }).then(data => {
    this.navCtrl.push(TabsPage, {
    name: this.pseudo,
    photo: url,
     });
      });

})

你能添加错误吗?@yazantahhan这是错误:错误N代码:“身份验证/内部错误”消息:“照片URL太长”。Prototype NCA你能添加错误吗?@yazantahhan这是错误:错误N代码:“身份验证/内部错误”消息:“照片URL太长”。Prototype N询问答案。它起作用了。在我的例子中,我必须这样做:firebase.storage().ref('pictures/'+user.uid+'/avatar.jpg');谢谢你的回答。它起作用了。在我的例子中,我必须这样做:firebase.storage().ref('pictures/'+user.uid+'/avatar.jpg');