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;
...
}
When you are using Firebase Cloud Functions with TypeScript (your code is in functions/src/index.ts
), you need to put the additional files in functions/lib
You'd like to upload 3 files to deploy your Cloud Function:
In order to do so via the Developer Console, you'll need to:
Once deployed, in the source tab for your function you'll see the three files displayed.
Alternatively, you can use gcloud to deploy your files via the following command:
gcloud beta functions deploy <functionName> --source=SOURCE
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.
While it is possible to use GCS, it's simple to include files in your source.
path.join(__dirname, 'your/path/file.ext')
I find this way the easiest when it comes to Firebase Functions:
firebase deploy --only functions
As you can see here the file is automatically added to the project in the GCP:
And you can access it in your node.js project:
protobuf.load(__dirname + '/schema.proto')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With