0

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

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Aiman Nazri
  • 35
  • 2
  • 9

1 Answers1

1

This is a formal issue because your application is being prevented to send data by the firebase it self , You should allow your application to write and read data . As a quick fix to this you should go to the ,

  Database tab in your relevant database--->select which type of DB yu are using
 -->Rules tab on the top column ,

There you would see a small piece of code which states read: 'false' and write 'false' , make them both 'true' and apply changes and save them. It should get it working. If it doesn't Let me know

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459