pnp / pnpjs

Fluent JavaScript API for SharePoint and Microsoft Graph REST APIs
https://pnp.github.io/pnpjs/
Other
753 stars 305 forks source link

getFileByServerRelativePath() returning corrupted file data #2973

Closed kaushalbcactus closed 5 months ago

kaushalbcactus commented 5 months ago

Major Version

3.x

Minor Version Number

3.24.0

Target environment

NodeJS

Additional environment details

I am using node js and certificate based authentication. I am trying to fetch file but returned array buffer is corrupted. When I perform same operation with GOT then it works perfectly

Expected or Desired Behavior

Return correct buffer or arraybuffer which can be converted to buffer

Observed Behavior

Returned incorrect or corrupted arraybuffer

Steps to Reproduce

import { spfi } from "@pnp/sp"; import "@pnp/sp/webs"; import "@pnp/sp/files"; import "@pnp/sp/folders";

const sp = spfi(...);

const buffer: ArrayBuffer = await sp.web.getFileByServerRelativePath("/sites/dev/documents/file.avi").getBuffer();

  1. Please check "Uint8Array" - PNPjs gives around 31070 While got gives 19316. image

  2. Whereas working with got command (https://www.npmjs.com/package/got)

image

  1. Sharing doc file as well. - Test_qerty.docx

Kindly provide help on this issue as I have implemented pnpjs on all my other functions and now stuck with this.

Please let me know if any other details needed. Thanks!

patrick-rodgers commented 5 months ago

We just call the response object's method. It might be an issue in node-fetch, have you checked their issue list for anything similar?

juliemturner commented 5 months ago

Note the file in your request that you posted is not the same file that you shared...

bcameron1231 commented 5 months ago

Closing this due to inactivity. If you continue to have issues please open a new issue, link to this issue, and provide any additional details available. Thanks!

github-actions[bot] commented 4 months ago

This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.