云功能:如何上传其他文件以在代码中使用? [英] Cloud Functions: how to upload additional file for use in code?
问题描述
我需要访问我的代码中的protoc
文件.在本地,我只是将其放在文件夹中,但是如何从已部署的Firebase函数中获取此文件?
I need to get access to protoc
file in my code. Locally I just put it in the folder but how to get this file from deployed Firebase functions?
const grpc = require('grpc');
const PROTO_PATH = __dirname + '\\protos\\prediction_service.proto';
exports.helloWorld = functions.https.onRequest((request, response){
var tensorflow_serving = grpc.load(PROTO_PATH).tensorflow.serving;
...
}
推荐答案
您要上传3个文件来部署您的Cloud Function:
You'd like to upload 3 files to deploy your Cloud Function:
- index.js
- package.json
- prediction_service.proto
要通过开发者控制台执行此操作,您需要:
In order to do so via the Developer Console, you'll need to:
- 转到Google Cloud开发者控制台> Cloud Functions>创建函数
- 在源代码"字段中,选择以下任一项:
- "ZIP上传",然后选择一个包含3个文件的zip文件,
- 来自云存储的ZIP"并选择GCS上的文件位置,
- "Cloud Source存储库"并提供您的回购详细信息
- Go to the Google Cloud Developer Console > Cloud Functions > Create Function
- In the "Source Code" field, choose either:
- "ZIP upload" and select a zip file including your 3 files,
- "ZIP from Cloud Storage" and select file location on GCS,
- "Cloud Source repository" and provide your repo details
部署后,在功能的源"选项卡中,您将看到显示的三个文件.
Once deployed, in the source tab for your function you'll see the three files displayed.
或者,您可以使用gcloud通过以下命令来部署文件:
Alternatively, you can use gcloud to deploy your files via the following command:
gcloud beta functions deploy <functionName> --source=SOURCE
其中源可以是Google Cloud Storage上的ZIP文件,对源存储库的引用或本地文件系统路径.我建议您查看 doc 此命令以获取全部详细信息.
where source can be a ZIP file on Google Cloud Storage, a reference to source repository or a local filesystem path. I'd recommend to have a look at the doc for this command for full details.
这篇关于云功能:如何上传其他文件以在代码中使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!