Blob object - how can I access the Blob's raw data as an ArrayBuffer?

How can I access the binary Blob data as an ArrayBuffer? I’m working with camera .jpg files. I have a special requirement for a client to load multiple photos into a zip file and post the zip to their server. I have custom code to generate the zip file that works and I’ve been able to use fetch to read the image files from local storage. How do I access the Blob data? Examples on the web show using a FileReader.readAsArayBuffer() but this doesn’t seem to be implemented. I’m using the latest expo 27

My code is:
var fileUri = ${FileSystem.documentDirectory}${filename};
const response = await fetch(fileUri);
const blob = await response.blob();
var reader = new FileReader();
var blob_data;
blob_data = reader.readAsBinaryString(blob); // doesn’t work
blob_data = reader.readAsArrayBuffer(blob); // doesn’t work seems to be an object - and I don’t see how to access its raw data

Unfortunately readAsArrayBuffer doesn’t work:

Original link:

  readAsArrayBuffer() {
    throw new Error('FileReader.readAsArrayBuffer is not implemented');

We’re going to have to think of a workaround together. I’m sorry that the implementation is missing this piece. This is something you may have to take to

Would readAsDataURL() work?

I’ve detached and am using ExpoKit now

Is it easy for me to expand FileReader?

Is all the source sitting somewhere in node_modules?

The code I sent you is from react-native in node_modules but I would try the readAsDataUrl first before you try anything too invasive

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.