Jacob
Jacob

Reputation: 19

How to get image from url in react

I am trying to upload an image saved as a URL. The 'img' field holds the URL for the image in firebase storage. How can I use this URL to upload an image in react?

firestore set up

Upvotes: 0

Views: 527

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599996

The URL in your screenshot starts with gs:// which means that it is a file stored in Cloud Storage.

Such URLs are not recognized by most browsers and libraries, but you can use the Firebase SDK for Cloud Storage to exchange it for a so-called download URL. This is a regular HTTP URL, that browser and libraries are expecting.

To learn how to get a download URL from your gs:// URL, have a look at the Firebase documentation on creating a reference to a file and downloading a file via a URL.

Upvotes: 1

Related Questions