Omer Zidkoni
Omer Zidkoni

Reputation: 15

Firebase API - getting the gs url from an uploaded image

I'm developing a React Native App using Expo and firebase. I'm Uploading a camera capture to firebase and then I need to get the google storage URL from Firebase back. I didn't understand how should I do this. When I looked in my firebase storage I saw the URL I wanted but didn't understand how to get it back in react native code :

capture from my firebase storage

Upvotes: 0

Views: 272

Answers (1)

Dharmaraj
Dharmaraj

Reputation: 50930

As @Frank mentioned in the comments, you can just use .toString() on the storage reference like this:

var storage = firebase.storage();

// Create a storage reference from our storage service
var storageRef = storage.ref();
var spaceRef = storageRef.child('/folder/image.png');
console.log(spaceRef.toString());

The Reference Object also has these properties:

bucket: <project-id>.appspot.com, fullPath: path to the object and name: name of the file/object

It also has the property .parent just in case you need to get some information from the parent directory.

Upvotes: 1

Related Questions