Firebase Cloud Functions EventContext.auth(迁移指南)
我遵循了《 Firebase SDK for Cloud Functions迁移指南》
并在将文件上传到云存储后集成新属性以获取用户身份验证信息时遇到问题.
I followed along the "Firebase SDK for Cloud Functions Migration Guide"
and had problems integrating the new properties to get the user auth information after uploading a file to the cloud storage.
exports.processFile = functions.storage.object().onFinalize((object, context) => {
console.log('Uploaded ', object, context);
});
如上面的代码片段所示,我已切换到onFinalize方法. object参数包含所有有关重新上载文件的信息.但是,上下文为空.
我想知道如何使用新属性EventContext.auth
检索用户的auth令牌,如下所示. 用户身份验证信息的新属性
As it can be seen in the snippet above, I have switched to the onFinalize method. The object parameter contains all information regrading the uploaded file. However the context is empty.
I am wondering how to retrieve the user's auth token with the new properties EventContext.auth
as shown here. New properties for user auth information
有关将文件写入存储的用户的任何信息都不会自动传递到您的Cloud Function.如果需要这些信息,通常将其传递到文件的路径中.
No information about the user that write the file to storage is passed to your Cloud Function automatically. If you need such information, it is common to pass it into the path of the file.
实时迁移文档中描述的属性数据库触发器仅适用于从实时数据库触发的云功能.它们不适用于存储触发器.
The properties described in the migration documentation for realtime database triggers only apply to Cloud Functions that are triggered from the Realtime Database. They do not apply to Storage triggers.