1

我正在尝试在Firebase 云存储文件上运行 Vision API文档文本检测。但我收到了这个错误:

  code: 7,
  details: 'Error opening file: gs://some-name.appspot.com/UsersUploadedFiles/2kuqctFfY0d0sF7ImcDk7Ci2MJo2/questions.pdf.',
  metadata: Metadata { internalRepr: Map {}, options: {} },
  note: 'Exception occurred in retry method that was not classified as transient'

我已经通过环境变量传递了服务帐户凭据,并且我正在调用 Vision API,nodejs如下所示:

const inputConfig = {
        mimeType: 'application/pdf',
        gcsSource: {
          uri: 'gs://some-name.appspot.com/UsersUploadedFiles/2kuqctFfY0d0sF7ImcDk7Ci2MJo2/questions.pdf',
        },
      };
      const outputConfig = {
        gcsDestination: {
          uri: 'gs://some-name.appspot.com/TranscribedData/2kuqctFfY0d0sF7ImcDk7Ci2MJo2/',
        },
      };

      const features = [{ type: "DOCUMENT_TEXT_DETECTION" }];
      const request: any = {
        requests: [
          {
            inputConfig: inputConfig,
            features: features,
            outputConfig: outputConfig,
          },
        ],
      };

      const [operation] = await client.asyncBatchAnnotateFiles(request);
      const [filesResponse] = await operation.promise();
      const destinationUri =
        filesResponse.responses[0].outputConfig.gcsDestination.uri;
4

1 回答 1

0

问题已解决。问题在于 GCloud Vision API 和 Firebase 项目是两个不同的项目。

这两个项目之间的名称略有不同,这就是我搞砸了

于 2020-10-18T06:59:00.543 回答