And*_*See 9 firebase google-cloud-functions firebase-storage
我想通过监听由functions.database.ref().onWrite()(而不是functions.storage.object().onChange())触发的事件来使用firebase云功能执行文件操作.
我注意到大多数使用云函数的示例functions.storage.object().onChange()触发了用于文件操作的云函数.有没有办法storageRef从内部获取functions.database.ref()并执行文件操作?
要从数据库触发的云功能中访问Firebase存储,您可以使用Google Cloud SDK.
来自我的一个应用:
const gcs = require('@google-cloud/storage')();
...
exports
.emojifyStory = functions.database.ref('/stories/{storyId}')
.onWrite(function(event) {
const filePath = event.data.val().filePath;
const file = gcs.bucket(bucket).file(filePath);
// Use the Vision API to detect labels
return visionClient.detectLabels(file)
.then(data => {
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2014 次 |
| 最近记录: |