从Firebase云功能获取UID [英] GET UID from firebase cloud functions
问题描述
当我触发存储事件时是否可以获取 uid
?
Is there a way to get the uid
when i trigger the storage events?
当图像上传到Firebase存储中时,我想创建一个缩略图,然后更新数据库中用户图像配置文件的url ...
I want create a thumb when the image is uploaded in to firebase storage and then update the url of the user image profile in database...
exports.uploadphoto = functions.storage.object().onChange(event => {
// ...
});
推荐答案
两个选项
您可以将图像存储到包含uId的路径中然后使用 event.data.name
获取文件路径
You could store your image to a path that contains the uId
then use event.data.name
to get the file path
OR
在上传时将其添加到自定义元数据中,然后通过以下方式访问云功能:
Add it to the custom metadata when you upload, then access in cloud functions by:
const metadata = event.data.metadata
const uId = metadata.uId
uId 可以是您上传时所称的名称.
uId can be whatever you call it when you upload.
上传自定义元数据文档
iOS: https://firebase.google.com/docs/storage/ios/file-metadata
Android: https://firebase.google.com/docs/storage/android/file-metadata
网络: https://firebase.google.com/docs/storage/web/file-metadata
这篇关于从Firebase云功能获取UID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!