2017-01-26 6 views
0

Imはfirebase docsに従って、ポリマーを使用してfirebaseに画像をアップロードしようとしています。ポリマー火災ベースに画像をアップロード

これは私が

_pushToFirebase: function() { 

     // SLUGGING THE NAME B4 WE EVEN SAVE IT!! 
     var sluggedname = this._slugify(this.$.crewName.value); 
     //FOR THE IMAGE 
     var file = this.$.crewProfilePic.value; 

     // Upload file 
     var uploadTask = this.$.query.storageRef.child('/crewprofileimages/' + file.name).put(file); 
     // Listen for state changes, errors, and completion of the upload. 
     uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, // or 'state_changed' 
     function(snapshot) { 
      // Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded 
      var progress = (snapshot.bytesTransferred/snapshot.totalBytes) * 100; 
      console.log('Upload is ' + progress + '% done'); 
      switch (snapshot.state) { 
      case firebase.storage.TaskState.PAUSED: // or 'paused' 
       console.log('Upload is paused'); 
       break; 
      case firebase.storage.TaskState.RUNNING: // or 'running' 
       console.log('Upload is running'); 
       break; 
      } 
     }, function(error) { 
     switch (error.code) { 
      case 'storage/unauthorized': 
      // User doesn't have permission to access the object 
      console.log('You dont have permission to access object'); 
      break; 

      case 'storage/canceled': 
      // User canceled the upload 
      console.log('User cancelled upload'); 
      break; 

      case 'storage/unknown': 
      // Unknown error occurred, inspect error.serverResponse 
      console.log(error.code); 
      break; 
     } 
     }, function() { 
     // Upload completed successfully, now we can get the download URL 
     var downloadURL = uploadTask.snapshot.downloadURL; 
     }); 




     // PUSHING TO FIREBASE 
     this.$.query.ref.push({ 
     name: this.$.crewName.value, 
     description: this.$.crewDescription.value, 
     createddate: new Date().toString(), 
     creator: this.$.createcrewlogin.user.uid, 
     slug: sluggedname, 
     profileimage: downloadURL, 
     members: { 
      memberuserid: this.$.createcrewlogin.user.uid, 
     } 
     }); 
    }, 

持っているものであると私は提出ヒットするたびにfirebaseクエリは、この

<!--STORE THE DATA IN CREWS DEFAULT SECTION--> 
    <firebase-query 
     id="query" 
     data="{{mycrews}}" 
     path="/crews"> 
    </firebase-query> 

のように見えます。私は私のコンソールでこのエラーが発生します

cannot read property of 'child' of undefinedどうすれば解決できますか?

+0

エラーの完全なスタックトレースと、それがスローする行番号 – ZuzEL

答えて

0

が遅れるかもしれないが簡単なエラーから、つまり、あなたがアクセスしようとしている要素が定義されていないようです、あなたは(ここでは子を)プロパティを要求する前にそれにアクセスする必要が

Firebase-クエリがありデータを保存できる場所のパスプロパティ。あなたがfirebase-queryとしてpolymerfire要素を使用している場合は、パスにアクセスして変更してから、()を押す必要があります。

this.$.query.path = yourPath ; 
this.$.query.put(file) ... etc 

あなたが提示エラーがこれからですが、よりよい解決策のためのより良いエラーを提供する必要があります

ので、代わりの

this.$.query.storageRef.child('/crewprofileimages/' + file.name).put(file); 

次のようなものを持っている必要があります。乾杯。

関連する問題