Angularfire2: How to retrieve file content from Firebase storage


Cupid

I am developing an Ionic application using Angulfire2.

I have successfully uploaded files to Firebase.

I found that the method getDownloadURL retrieves the file URL and it displays fine in the HTML page.

However, I can't find a way to download the content of the file. I am trying to perform an http request like this:

let headers = new HttpHeaders({ "Content-Type": "image/png" });
let imageGet = this.http.get(firestorageImageURI, { headers: headers }).subscribe((response) => {
    debugger;
});

But I got CORS error in console:

Access XMLHttpRequest via 'https://firebasestorage.googleapis.com/v0/b/xxxx.appspot.com/o/edls%2Fb2478a2b-48eb-4056-94c8-e83d858cd519%2Fb2478a2b-48eb-4056-94c8-e83d858cd519_b_1603046492694. 'alt=media&token=8ce76185-dd05-451e-919e-49f695145237' from alt has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header on the requested resource.

I also configured CORS to allow all origins as detailed here : https://firebase.google.com/docs/storage/web/download-files

But it didn't change the error.

I also changed the storage rule to:

rules_version = '2'; 
service firebase.storage {   
  match /b/{bucket}/o {
     match /{allPaths=**} {
          allow read, write: if true;
     }   
  } 
}

Does anyone know how to download files from Firebase Storage using angularfire2?

thanks in advance

Cupid

Found the problem, it's the header and shouldn't be sent to the query.

Related


Angularfire2: How to retrieve file content from Firebase storage

Cupid I am developing an Ionic application using Angulfire2. I have successfully uploaded files to Firebase. I found that the method getDownloadURL retrieves the file URL and it displays fine in the HTML page. However, I can't find a way to download the conten

Angularfire2: How to retrieve file content from Firebase storage

Cupid I am developing an Ionic application using Angulfire2. I have successfully uploaded files to Firebase. I found that the method getDownloadURL retrieves the file URL and it displays fine in the HTML page. However, I can't find a way to download the conten

Angularfire2: How to retrieve file content from Firebase storage

Cupid I am developing an Ionic application using Angulfire2. I have successfully uploaded files to Firebase. I found that the method getDownloadURL retrieves the file URL and it displays fine in the HTML page. However, I can't find a way to download the conten

Angularfire2: How to retrieve file content from Firebase storage

Cupid I am developing an Ionic application using Angulfire2. I have successfully uploaded files to Firebase. I found that the method getDownloadURL retrieves the file URL and it displays fine in the HTML page. However, I can't find a way to download the conten

Upload file to Firebase Storage using AngularFire2

Emanuela Colta I'm working on a project with Angular2 and Firebase and am willing to upload images to Firebase Storage. So I created components with constructors, functions and templates. I'm not sure if the way of declaring the variable firebaseApp is public

Upload file to Firebase Storage using AngularFire2

Emanuela Colta I'm working on a project with Angular2 and Firebase and am willing to upload images to Firebase Storage. So I created components with constructors, functions and templates. I'm not sure if the way of declaring the variable firebaseApp is public

Upload file to Firebase Storage using AngularFire2

Emanuela Colta I'm working on a project with Angular2 and Firebase and am willing to upload images to Firebase Storage. So I created components with constructors, functions and templates. I'm not sure if the way of declaring the variable firebaseApp is public

Upload file to Firebase Storage using AngularFire2

Emanuela Colta I'm working on a project with Angular2 and Firebase and am willing to upload images to Firebase Storage. So I created components with constructors, functions and templates. I'm not sure if the way of declaring the variable firebaseApp is public

Retrieve json file from firebase storage

David I want to be able to get a json file from Firebase Storage to use. I don't need to push back. Can Firebase Storage benefit me? If so, how can I do this with Angular? If not, is Firebase Database a better choice? I have downloaded firebase and angularfire

Retrieve json file from firebase storage

David I want to be able to get a json file from Firebase Storage to use. I don't need to push back. Can Firebase Storage benefit me? If so, how can I do this with Angular? If not, is Firebase Database a better choice? I have downloaded firebase and angularfire

Read the value/content of a file from Firebase Storage

Philip Is it possible to read the value of a file without using the download function? replace: storageRef.child('text.txt').getDownloadURL().then(function() { ... }); It's just like: storageRef.child('text.txt').getValue().then(function(value) { alert(va

Read the value/content of a file from Firebase Storage

Philip Is it possible to read the value of a file without using the download function? replace: storageRef.child('text.txt').getDownloadURL().then(function() { ... }); It's just like: storageRef.child('text.txt').getValue().then(function(value) { alert(va

Read the value/content of a file from Firebase Storage

Philip Is it possible to read the value of a file without using the download function? replace: storageRef.child('text.txt').getDownloadURL().then(function() { ... }); It's just like: storageRef.child('text.txt').getValue().then(function(value) { alert(va

Read the value/content of a file from Firebase Storage

Philip Is it possible to read the value of a file without using the download function? replace: storageRef.child('text.txt').getDownloadURL().then(function() { ... }); It's just like: storageRef.child('text.txt').getValue().then(function(value) { alert(va