如何在单个事务中将图像上传到Firebase存储并将引用保存在数据库中? [英] How to upload image to firebase storage and save reference in the database in single transaction?

查看:41
本文介绍了如何在单个事务中将图像上传到Firebase存储并将引用保存在数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将图像上传到Firebase存储并将其链接保存在Firebase数据库中.出于任何原因将链接保存到数据库都会失败,然后我的存储中有未使用的,未链接的映像.是否可以以某种方式确保在上传后将指向图像的链接保存在数据库中?

I would like to upload image to firebase storage and save link to it in the firebase database. Saving link to database can fail for whatever reason and then I have unused, unlinked image in the storage. Is it possible to somehow ensure that after upload link to the image is saved in the database?

推荐答案

这是除了使用事务之外的另一种方法.您可以使用Firebase Cloud Functions存储触发器.您可以编写一个云函数来获取上载图像的下载URL,然后将其推送到Firebase数据库.

This is another approach other than using transaction. You can use Firebase Cloud Functions Storage Trigger. You can write a cloud function to get the download URL of the uploaded image and then push it to firebase database.

通过firebase观看有关Cloud Function Storage Trigger的此视频

这篇关于如何在单个事务中将图像上传到Firebase存储并将引用保存在数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆