Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在firebase云功能中使用外部资源(媒体),无需存储桶_Firebase_Google Cloud Functions - Fatal编程技术网

在firebase云功能中使用外部资源(媒体),无需存储桶

在firebase云功能中使用外部资源(媒体),无需存储桶,firebase,google-cloud-functions,Firebase,Google Cloud Functions,假设我有一张发票要生成,发票包含公司的徽标和其他图像,这些图像将在每次生成发票时使用 我需要从存储桶中取出这些图像吗?或者我可以将其加载到functions目录中并从那里使用它,类似于servicecomport.json文件加载到函数中的方式吗 编辑:我的想法是 functions/ ├── index.js ├── image.jpg 在index.js中 const path = require("path"); const pathToImage = path.jo

假设我有一张发票要生成,发票包含公司的徽标和其他图像,这些图像将在每次生成发票时使用

我需要从存储桶中取出这些图像吗?或者我可以将其加载到
functions
目录中并从那里使用它,类似于
servicecomport.json
文件加载到函数中的方式吗

编辑:我的想法是

functions/
├── index.js
├── image.jpg
index.js中

const path = require("path");
const pathToImage = path.join(__dirname,'/image.jpg');

Firebase/Cloud Functions部署过程会打包
Functions
目录中的所有内容,并将其部署到函数的运行时。这意味着您确实可以在云函数部署中包含所需的任何静态文件,然后从代码中访问它们

这就是您也包括服务帐户的方式,或者当您将云功能代码拆分到多个文件中,然后将这些文件包含到
index.js
中时会发生什么