Fix: Update file buffer handling to use BinaryLike for improved data integrity#340
Fix: Update file buffer handling to use BinaryLike for improved data integrity#340Aryan0699 wants to merge 2 commits intoshopstr-eng:mainfrom
Conversation
|
@Aryan0699 is attempting to deploy a commit to the shopstr-eng Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adjusts SHA256 hashing input types for uploaded files to satisfy newer TypeScript expectations around Node.js crypto’s BinaryLike input.
Changes:
- Adds a
BinaryLiketype import and converts the upload buffer toUint8Arraybefore hashing - Updates size reporting to use the new binary data length
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Nit pick: Consider reusing binaryData in the upload body instead of creating another Uint8Array: This keeps the binary handling consistent throughout the function. |
|
Actually it was giving a type error when i tried to do that saying that expected was ArrayBuffer but got ArrayBufferLike . |
no issues, good as it is. |
Description
When computing the SHA256 hash of uploaded files, we were using a Node.js Buffer directly. However, the Node.js crypto API requires a stricter type called BinaryLike, which doesn't fully accept Buffer in newer TypeScript versions
Solution :
Converted the Buffer to Uint8Array (a standard binary type) using Uint8Array.from(fileBuffer).
The fix is minimal (one line change) and has zero impact on actual functionality—it's purely a type compatibility improvement.
Resolved or fixed issue
noneAffirmation