HomePhabricator
Diffusion Comm ca7dc26f16b4

[native] Implement BlobUtils expo-module on Android

Description

[native] Implement BlobUtils expo-module on Android

Summary:
The core part of ENG-3718. The issue description is important to understand the context of this diff.
In short: Implemented two functions that provide a way to directly convert Blob <--> ArrayBuffer without going through base64 encoding/decoding which is extremely inefficient.

Other helpful resources:

  • The library that does the same using Java and raw JSI: C++, Java

Depends on D7973

Test Plan:
Built the Android, tested using the following snippet:

const array1 = new Uint8Array([1, 2, 3, 4, 5]);
const blob1 = blobFromArrayBuffer(array1.buffer);
console.log('blob1', blob1);

const decoded = new Uint8Array(arrayBufferFromBlob(blob1));
console.log('decoded', decoded);

const blob2 = blobFromArrayBuffer(decoded.buffer);
console.log('blob2', blob2);
// line below requires amending exports in native/media/blob-utils.js
console.log('Another way:', await blobToDataURI(blob2).then(dataURIToIntArray));

Reviewers: atul, marcin

Reviewed By: atul, marcin

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D7974

Details

Provenance
bartekAuthored on May 25 2023, 4:44 AM
Reviewer
atul
Differential Revision
D7974: [native] Implement BlobUtils expo-module on Android
Parents
rCOMM42bca7921375: [native] Add BlobUtils expo-module and add iOS implementation
Branches
Unknown
Tags
Unknown