I'm trying to run Vision API Document Text Detection on a Firebase Cloud Storage file. But I'm getting this error:
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'
I've passed the service account credentials via environment variables and I'm calling the vision API from nodejs
like this:
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;
The problem is resolved. The issue was that the GCloud Vision API and the Firebase project were two different projects.
There was a slight name difference between these two project, that's what messed up this for me