【发布时间】:2018-05-28 08:30:54
【问题描述】:
我正在使用 Cloud Storage for Firebase,但不知道如何访问存储文件
根据https://firebase.google.com/docs/storage/web/start 官方指南和https://firebase.google.com/docs/storage/web/create-reference,此代码应返回根引用
let admin = require('firebase-admin')
admin.initializeApp({...})
let storageRef = admin.storage().ref()
但它会抛出一个错误说
TypeError: admin.storage(...).ref 不是函数
package.json
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {...},
"dependencies": {
"@google-cloud/storage": "^1.5.1",
"firebase": "^4.8.0",
"firebase-admin": "~5.4.2",
"firebase-functions": "^0.7.1",
"pdfkit": "^0.8.3",
"uuid": "^3.1.0"
},
"private": true
}
节点-v => v7.7.4
我的最终目标是下载文件或将 pdf 文件上传到存储。
【问题讨论】:
-
你在功能上吗?如果是,请使用
bucket = admin.storage().bucket(),功能管理员不使用 Web api -
感谢您的回复,是的,我可以通过这种方式访问存储桶,并且可以使用
bucket.file('images/snow.jpg')访问文件,但我想返回/下载文件以响应云功能。可以指导一下吗? -
我试过
bucket.file('images/snow.jpg').getDownloadURL(),但它说bucket.file(...).getDownloadURL is not a function -
嘿 .. 我不断收到 .. 错误:没有
client_email就无法签署数据。在哪里可以配置 client_email ?
标签: node.js firebase firebase-storage firebase-admin