Salma
Salma

Reputation: 1280

how to upload images to firebase storage then store the image url in firestore?

I'm trying to upload images to firebase storage and use that image url as metadata in firestore, however the image url is always null. (I'm assuming that the image hasn't finished uploading by the time i add it to my firestore).

Whenever i try to save this image uri to firestore it's always null. so what's the issue here?

Upvotes: 3

Views: 2264

Answers (1)

Harsha pulikollu
Harsha pulikollu

Reputation: 2436

Try

String downloadUrl =
await (await uploadTask.onComplete).ref.getDownloadURL();

instead of your

Uri location = (await uploadTask.onComplete).uploadSessionUri;

As per docs of firebase UploadSessionUri is used to resume the upload of same file within a span of approx. week Here is the link for docs

Upvotes: 2

Related Questions