【发布时间】:2019-02-11 20:25:42
【问题描述】:
我正在构建一个应用程序,我的目标是每次有人将图像上传到 Firebase 存储时,云功能都会调整该图像的大小。
...
import * as Storage from '@google-cloud/storage'
const gcs = new Storage()
...
exports.resizeImage = functions.storage.object().onFinalize( async object => {
const bucket = gcs.bucket(object.bucket);
const filePath = object.name;
const fileName = filePath.split('/').pop();
const bucketDir = dirname(filePath);
....
当我尝试部署这个功能时,我得到了这个错误:
Error: Error occurred while parsing your function triggers.
TypeError: Storage is not a constructor
我尝试使用“new Storage()”或仅使用“Storage”,但没有任何效果。
我是这里的新手,所以如果有什么我忘了让你调试,请告诉我。
谢谢!
谷歌云/存储:2.0.0
节点js:v8.11.4
【问题讨论】:
标签: node.js firebase google-cloud-storage google-cloud-functions