I'm using ionic framework to navigate image file from a registered user that upload the image using uploadcare and send direct image information to the firestore firebase database. I'm using the 'ionic serve' command to open my application which opens in Mozilla Firefox. When I upload the image it got some error in my inspect element console showing:
FirebaseError: [code=permission-denied]: Missing or insufficient permissions
Here my code for uploader.page.ts
import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http'
import {AngularFirestore} from '@angular/fire/firestore';
import {UserService} from '../user.service';
import { firestore } from 'firebase/app';
@Component({
selector: 'app-uploader',
templateUrl: './uploader.page.html',
styleUrls: ['./uploader.page.scss'],
})
export class UploaderPage implements OnInit {
imageURL: string
desc : string
constructor(
public http: Http,
public afstore: AngularFirestore,
public user: UserService) { }
ngOnInit() {
}
createPost(){
const image = this.imageURL
const desc = this.desc
this.afstore.doc('users/${this.user.getUID()}').update({
posts: firestore.FieldValue.arrayUnion({
image,
desc
})
})
}
fileChanged(event){
const files = event.target.files
const data = new FormData()
data.append('file', files[0])
data.append('UPLOADCARE_STORE', '1')
data.append('UPLOADCARE_PUB_KEY','46efb6e9d65277034002')
this.http.post('https://upload.uploadcare.com/base/', data)
.subscribe(event => {
console.log(event)
this.imageURL = event.json().file
})
}
}
I expect the database cloud firestore will mention what registered user upload with specific information