Abd*_*lah 7 node.js firebase firebase-storage firebase-admin
我正在使用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()
Run Code Online (Sandbox Code Playgroud)
但这引发了错误
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
}
Run Code Online (Sandbox Code Playgroud)
节点-v => v7.7.4
我的最终目标是下载文件或将pdf文件上传到存储。
您正在使用Cloud Functions和Firebase Admin SDK尝试访问您的存储桶。您引用的入门指南讨论的是使用Web Api for Firebase而不是管理员使用的客户端Web Apps。那里的功能不同,因为它是不同的SDK(即使名称保持不变)。Storage您尝试访问的对象没有ref()功能,只有app和bucket()。https://firebase.google.com/docs/reference/admin/node/admin.storage.Storage
尝试直接使用Google Cloud API:https://cloud.google.com/storage/docs/creating-buckets#storage-create-bucket-nodejs
| 归档时间: |
|
| 查看次数: |
5092 次 |
| 最近记录: |