Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. onSavePost() {
  2. const title = this.postForm.get('title').value;
  3. const description = this.postForm.get('description').value;
  4.  
  5. const arrayPath = this.postForm.get('post').value.split("\\"); // arrayPath[2] is our post's name ;)
  6. console.log(arrayPath);
  7.  
  8. //var postUrl = 'empty';
  9. const storageRef = firebase.storage().ref();
  10. console.log(storageRef);
  11. const postRef = storageRef.child('/posts/' + arrayPath[2]);
  12. console.log(postRef);
  13.  
  14. postRef.getDownloadURL().then( (url) => {
  15. this.postUrl = url.toString();
  16. console.log(this.postUrl);
  17. this.newPost = new Post(title,this.postUrl,0,0,[],description);
  18. this.currentArtistId = this.route.snapshot.params['id']; // get the Id of the artist that I'm looking at
  19. this.postService.createNewPost(this.newPost,this.currentArtistId); // create the new post under the current artist
  20. this.router.navigate(['/artists',this.currentArtistId,'posts']);
  21.  
  22. }).catch(function (error) {
  23. // Handle any errors
  24. console.log("error in getting download url.." + error);
  25. });
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement