Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't save image/png in node #31873

Open
n-berilov opened this issue Nov 21, 2024 · 3 comments
Open

Can't save image/png in node #31873

n-berilov opened this issue Nov 21, 2024 · 3 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. Cognitive - Form Recognizer customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@n-berilov
Copy link

n-berilov commented Nov 21, 2024

For the following endpoint /documentModels/{modelId}/analyzeResults/{resultId}/figures/{figureId} image is not getting saved. Seems like some encoding problem because it works fine in postman.

Response body is types as Uint8Array, but it seems to be a string.

Part of the output when saving in node:

�PNG
�
���
IHDR���b���q��������l���	pHYs����������+����+�IDATx��{�Ue���h��eV��Y*%D�2�]�+���&X����a��.���K�4KJ�Z�0R�����EPI�LD2/deZ�%���q?

Part of output when using postman where image saved correctly:

�PNG
�
���
IHDR���b���q��������l���	pHYs����������+����+�IDATx��{�Ue���h��eV��Y*ȥD�2�]�+���&٘����a��.���K�4KJ�Z�0R�����EPI�LD2/deZ�%̜ߧ�q?
import DocumentIntelligence, {
  isUnexpected,
} from "@azure-rest/ai-document-intelligence";

  const client = DocumentIntelligence(
    endpoint,
    {
      key,
    },
    { apiVersion: "2024-07-31-preview" }
  );

const res = await client
    .path(
      "/documentModels/{modelId}/analyzeResults/{resultId}/figures/{figureId}",
      "prebuilt-layout",
      "2a5da62f-1101-4d7e-8b02-93904e34a0b6",
      "1.1"
    )
    .get();
  if (isUnexpected(res)) {
    throw res.body.error;
  }

  fs.writeFileSync("output.png", res.body, "binary");

Version: "@azure-rest/ai-document-intelligence": "1.0.0-beta.3"

@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. Cognitive - Form Recognizer customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team. labels Nov 21, 2024
Copy link

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ctstone @vkurpad.

@HarshaNalluru
Copy link
Member

Thanks for logging the issue @n-berilov.
We're working on this already. Will keep you posted once we fix this.

@n-berilov
Copy link
Author

Maybe related: #27748

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. Cognitive - Form Recognizer customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

2 participants