打开云存储文件时发生gcloud Vision API错误

分享于 

2分钟阅读

互联网

  繁體

问题:

我尝试在Firebase Cloud Storage文件上运行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'



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


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;




答案1:

问题已得以解决,问题是GCloud Vision API和firebase项目是两个不同的项目,

这两个项目之间的名称略有不同,这就是让我感到困惑的原因



文件  API  vis    存储  Visio