部署GCP时未上传本地.js文件

时间:2020-09-18 22:37:00

标签: node.js google-cloud-platform google-cloud-functions

我跟随this basic tutorial部署了三个功能。因此,目前我已经成功部署了三个Cloud Functions。

我在index.js文件中编写了第四个函数:

const userInput = require('user-input.js');

// more code in the middle from the tutorial

exports.compareUserToDetectedText = async (event) => {
  input = userInput.getUserInput(`${originalFilename}.txt`);
  console.log(input);
}

并在与index.js文件相同的目录中创建了一个新文件user-input.js:

// Get a reference to the Cloud Storage component
const {Storage} = require('@google-cloud/storage');
const storage = new Storage();

exports.getUserInput = (filename) => {
  const bucket = storage.bucket('my_bucket_name');
  const remoteFile = bucket.file(filename);

 }

当我尝试部署此功能时:

gcloud functions deploy ocr-compare \
--runtime nodejs10 \
--trigger-bucket [my trigger bucket] \
--entry-point compareUserToDetectedText \
--set-env-vars "^:^GCP_PROJECT=[project ID],RESULT_BUCKET=[my result bucket]"

我在日志中发现此错误:

"Function 'compareUserToDetectedText' is not defined in the provided module." 
Did you specify the correct target function to execute?
Could not load the function, shutting down.

当我deploy the functions in the tutorial时,源代码将针对该功能进行更新。为什么没有为此新的compareUserToDetectedText函数上载源代码?

0 个答案:

没有答案