I am uploading text files in Firebase storage and storing some data in Firebase real-time database. No problem in doing the above thing.
Also, I am able to fetch all the files present in firestorage along with the URL of text file. But I am not able to read the content inside a text file.
I am using below code to fetch the data
I am calling getfileDetails() method in init to store all data in fileDetailList before calling below code
this.uploadService.fileDetailList.snapshotChanges().subscribe(
list => {
console.log("before fileListDetails= ");
this.fileListDetails = list.map((item) => {
return item.payload.val();
});
console.log("fileListDetails= " + JSON.stringify(this.fileListDetails)); //logs attached below
this.FileDetailsList = this.fileListDetails;
this.FileDetailsList.forEach((item) => {
console.log("item= " + item.imgUrl);
// to get the text from file
this.http.get<string>(item.imgUrl).subscribe(
(item11)=>{
console.log("file read= "+item11); //getting error Here
}
);
});
}
);
my uploadService.ts method
fileDetailList:AngularFireList<any>;
constructor(private firebase:AngularFireDatabase) { }
getfileDetails()
{
console.log("getfileDetails");
this.fileDetailList=this.firebase.list('FileDetails');
}
logs Details
fileListDetails= [{"caption":"nkn,","category":"hello.txt","imgUrl":"https://firebasestorage.googleapis.com/...."}]
when I am hitting imgUrl in the browser directly I am able to get the text