简体   繁体   English

DocumentError“权限‘documentai.processors.processOnline’在资源‘我的处理器’上被拒绝(或者它可能不存在)

[英]DocumentError "Permission 'documentai.processors.processOnline' denied on resource 'my processors' (or it may not exist)

im trying to implement documentai with NodeJS我正在尝试用 NodeJS 实现 documentai

and im stuck while trying to run DocumentProcessorServiceClient()我在尝试运行 DocumentProcessorServiceClient() 时卡住了

i got this error我收到这个错误

    Error: 7 PERMISSION_DENIED: Permission 'documentai.processors.processOnline' denied on resource '//documentai.googleapis.com/projects/<project-id>/locations/us/processors/<processor-id>' (or it may not exist).
      at Object.callErrorFromStatus (C:\Users\dev\me-ocr\node_modules\@grpc\grpc-js\build\src\call.js:31:26)
      at Object.onReceiveStatus (C:\Users\dev\me-ocr\node_modules\@grpc\grpc-js\build\src\client.js:176:52)
      at Object.onReceiveStatus (C:\Users\dev\me-ocr\node_modules\@grpc\grpc-js\build\src\client-interceptors.js:336:141)
      at Object.onReceiveStatus (C:\Users\dev\me-ocr\node_modules\@grpc\grpc-js\build\src\client-interceptors.js:299:181)
      at C:\Users\dev\me-ocr\node_modules\@grpc\grpc-js\build\src\call-stream.js:130:78 
      at processTicksAndRejections (internal/process/task_queues.js:79:11) {
    code: 7,
    details: "Permission 'documentai.processors.processOnline' denied on resource '//documentai.googleapis.com/projects/<project-id>/locations/us/processors/<processor-id>' (or it may not exist).",
    metadata: Metadata { internalRepr: [Map], options: {} },
    note: 'Exception occurred in retry method that was not classified as transient'
  }

here is my function这是我的 function

const doScan = async (filePath: string) => {
  try {
    // Configure the request for processing the PDF
    const name = `projects/${projectId}/locations/${location}/processors/${processorId}`; 
    // Read the file into memory.
    const imageFile = await fs.promises.readFile(filePath); 
    // Convert the image data to a Buffer and base64 encode it.
    const encodedImage = Buffer.from(imageFile).toString("base64"); 
    const request = {
      name,
      document: {
        content: encodedImage,
        mimeType: "application/pdf",
      },
    };   
    // Recognizes text entities in the PDF document
    const [result] = await client.processDocument(request);  
    const { document }: any = result;
    const { text }: any = document;
    const getText = (textAnchor: any) => {
      if (!textAnchor.textSegments || textAnchor.textSegments.length === 0) {
        return "";
      } 
      // First shard in document doesn't have startIndex property
      const startIndex = textAnchor.textSegments[0].startIndex || 0;
      const endIndex = textAnchor.textSegments[0].endIndex; 
      return text.substring(startIndex, endIndex);
    }; 
    // Read the text recognition output from the processor
    console.log("The document contains the following paragraphs:");
    const [page1] = document.pages;
    const { paragraphs } = page1;

    for (const paragraph of paragraphs) {
      const paragraphText = getText(paragraph.layout.textAnchor);
      console.log(`Paragraph text:\n${paragraphText}`);
    }
  } catch (err) {
    console.log({ err });
  }
};

i've already try change the name using this, but it ends the same... client.processorPath(projectId, location, processorId);我已经尝试使用它更改名称,但它的结尾相同... client.processorPath(projectId, location, processorId);

Thanks谢谢

According to comment from the poster, the issue was resolved by upgrading to the latest version of the Document AI Node.JS Package根据发布者的评论,通过升级到最新版本的 Document AI Node.JS Package 解决了这个问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 资源上的权限“documentai.processors.processOnline”被拒绝(或者它可能不存在) - Permission 'documentai.processors.processOnline' denied on resource (or it may not exist) PERMISSION_DENIED:资源“//documentai.googleapis.com/project...”上的权限“documentai.processors.processOnline”被拒绝(或者它可能不存在)。 - PERMISSION_DENIED: Permission 'documentai.processors.processOnline' denied on resource '//documentai.googleapis.com/project...'(or it may not exist)." 资源上的权限“cloudkms.cryptoKeyVersions.viewPublicKey”被拒绝,或者它可能不存在 - Permission 'cloudkms.cryptoKeyVersions.viewPublicKey' denied on resource or it may not exist 权限 bigquery.tables.get 被拒绝或可能不存在 - Permission bigquery.tables.get denied or it may not exist gcloud app deploy 失败并显示 Failed to create cloud build: Permission denied on 'locations/xyz' (or it may not exist) - gcloud app deploy is failing with Failed to create cloud build: Permission denied on 'locations/xyz' (or it may not exist) Terraform:googleapi:错误 403:资源项目权限被拒绝 - Terraform: googleapi: Error 403: Permission denied on resource project PERMISSION_DENIED:项目配额不足,无法满足请求:资源 - PERMISSION_DENIED: Insufficient project quota to satisfy request: resource 错误:被拒绝:资源上的权限“artifactregistry.repositories.downloadArtifacts”被拒绝 - Error: denied: Permission "artifactregistry.repositories.downloadArtifacts" denied on resource 资源上的权限“firebasemessagingcampaigns.campaigns.create”被拒绝 - Permission 'firebasemessagingcampaigns.campaigns.create' denied on resource 消息处理器在 MI 4.1 中处于休眠状态 - Messages Processors get dormant in MI 4.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM