Skip to content

Commit

Permalink
fix: read id from url
Browse files Browse the repository at this point in the history
  • Loading branch information
oott123 committed Mar 22, 2024
1 parent f81c8da commit 2cf2f96
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ocr/azure-ocr.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ 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
for (let i = 0; i < totalTimes; i++) {
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}...`)
Expand Down

0 comments on commit 2cf2f96

Please sign in to comment.