Skip to content

feat: accept ArrayBuffer and ArrayBufferView parts in Blob and File - #58030

Open
paradowstack wants to merge 3 commits into
react:mainfrom
paradowstack:feat/blob-from-array-buffer
Open

feat: accept ArrayBuffer and ArrayBufferView parts in Blob and File#58030
paradowstack wants to merge 3 commits into
react:mainfrom
paradowstack:feat/blob-from-array-buffer

Conversation

@paradowstack

@paradowstack paradowstack commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Rebase Note:

This branch is stacked on #57937 (Promise<ArrayBuffer> for Java/ObjC TurboModules) and #58029 (feat: support Array as a TurboModule method parameter) and must be rebased onto main once that lands. For now review only the last commit.

Summary:

new Blob([arrayBuffer]) threw Creating blobs from 'ArrayBuffer' and 'ArrayBufferView' are not supported. The wire format carried only {type: 'string' | 'blob'} descriptors through a ReadableArray, which has no way to carry raw bytes, so binary parts had nowhere to go.

createFromParts gains a second argument, binaryParts: Array<ArrayBuffer>. A binary part becomes {type: 'binaryPart', data: <index>} in the existing ordered descriptor list, pointing into that parallel array — ordering is preserved, and the bytes travel over the Array<ArrayBuffer> path rather than being encoded into a string. A whole buffer is forwarded as-is; only a partial ArrayBufferView is sliced, because the wire format carries whole buffers. Detached and zero-length parts contribute nothing and are dropped.

Changelog:

[GENERAL] [BREAKING] - Blob and File constructors accept ArrayBuffer and ArrayBufferView parts

Test Plan:

  • Blob-test / BlobManager-test / File-test cover binary parts, mixed-part ordering, whole-buffer vs. partial-view forwarding, empty and detached buffers, Float64Array and DataView sizing, and the W3C USVString fallback for everything that is neither a Blob nor a BufferSource.
  • BlobModuleTest covers createFromParts with one, several and out-of-range binary parts, mixed-part ordering, and that a stored part does not alias the source buffer.
  • RCTBlobManagerTests covers createFromParts with binary parts, an out-of-range index, and a wrongly-typed part.
  • globals.d.ts and the globals.tsx type tests accept the new BlobPart constructor arguments.
  • Android and C++ API snapshots updated.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 20, 2026
@paradowstack
paradowstack force-pushed the feat/blob-from-array-buffer branch from 199fb07 to fabef5a Compare August 20, 2026 13:33
@github-actions

Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

@paradowstack
paradowstack force-pushed the feat/blob-from-array-buffer branch 2 times, most recently from 049beb5 to 551fa69 Compare August 20, 2026 14:06
@paradowstack
paradowstack marked this pull request as ready for review August 20, 2026 14:08
@paradowstack
paradowstack force-pushed the feat/blob-from-array-buffer branch from 551fa69 to 28267b7 Compare August 20, 2026 14:38
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 20, 2026
@paradowstack
paradowstack force-pushed the feat/blob-from-array-buffer branch from 28267b7 to 9f53665 Compare August 21, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant