Flutter Firebase - App Check
Flutter Web
Before hand, I uploaded the images to bucket manually.
I need help to fetch the data from firebase storage bucket.
I was trying to fetch images stored as jpeg format in 1920x1080p resolution.
Future<String> imageData = FirebaseStorage.instance .ref() .child('images') .child('panda_16x9.jpeg') .getDownloadURL();
Then i am passing imageData to FutureBuilder
FutureBuilder<String>( future: imageData, builder: (context, imageUrl) { if(imageUrl.hasError) { return __(widget saying error)__ } if(imageUrl.hasData) { return Image.network(imageUrl.data!); } return __(loading widget)__ });
I also tried getting data is Uint8List but no success because the main issue is Permission Denied from server
Issues
- initially was getting cors error
- no "access-control-origin-access" on the Request Response header.
- fixed it by going to GCP and opening the cloud shell and adding the cors rules.
- Open Google Cloud Console
- Select the project same as firebase project
- open the cloud shell
- The create a file
touch cors.json
- use vim to edit
vim cors.json
[ { "origin":["*"], // In production we will replace it with original domain name "method":["GET","POST","UPDATE","DELETE"], "header":["Access-Control-Allow-Origin"], "maxAgeSeconds":3600, } ]
- run command
gsutil cors set cors.json gs://<your-bucker>
You can find the bucket url from firebase storage section
- After i fixed the cors issue, i starting getting Invalid App Check token
- It was an easy fix. Just needed to follow as per guide
- I am now getting error "Permission Denied" 403 Status Code