From 2cf2f96da3ddfc4b89b261274694e7fdc48abfde Mon Sep 17 00:00:00 2001 From: oott123 Date: Fri, 22 Mar 2024 18:23:12 +0800 Subject: [PATCH] fix: read id from url --- src/ocr/azure-ocr.service.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ocr/azure-ocr.service.ts b/src/ocr/azure-ocr.service.ts index b8eef0e..b9ab183 100644 --- a/src/ocr/azure-ocr.service.ts +++ b/src/ocr/azure-ocr.service.ts @@ -29,6 +29,7 @@ export class AzureOCRService implements OCRService { const request = await this.client.readInStream(imgBuffer, { readingOrder: 'natural', }) + debug('read request finished', request._response) const results = await (async () => { const totalTimes = 30 @@ -36,7 +37,9 @@ export class AzureOCRService implements OCRService { await new Promise((r) => setTimeout(r, 500)) const result = await this.client.getReadResult( - request._response.parsedHeaders['apim-request-id'], + request._response.parsedHeaders.operationLocation?.match( + /[^/]+$/, + )![0], ) if (result._response.parsedBody.status === 'running') { debug(`task running ${i + 1}/${totalTimes}...`)