Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- onSavePost() {
- const title = this.postForm.get('title').value;
- const description = this.postForm.get('description').value;
- const arrayPath = this.postForm.get('post').value.split("\\"); // arrayPath[2] is our post's name ;)
- console.log(arrayPath);
- //var postUrl = 'empty';
- const storageRef = firebase.storage().ref();
- console.log(storageRef);
- const postRef = storageRef.child('/posts/' + arrayPath[2]);
- console.log(postRef);
- postRef.getDownloadURL().then( (url) => {
- this.postUrl = url.toString();
- console.log(this.postUrl);
- this.newPost = new Post(title,this.postUrl,0,0,[],description);
- this.currentArtistId = this.route.snapshot.params['id']; // get the Id of the artist that I'm looking at
- this.postService.createNewPost(this.newPost,this.currentArtistId); // create the new post under the current artist
- this.router.navigate(['/artists',this.currentArtistId,'posts']);
- }).catch(function (error) {
- // Handle any errors
- console.log("error in getting download url.." + error);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement