Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement FileReader.readAsArrayBuffer #21209

Smarticles101 opened this issue Sep 19, 2018 · 4 comments

Implement FileReader.readAsArrayBuffer #21209

Smarticles101 opened this issue Sep 19, 2018 · 4 comments


Copy link

@Smarticles101 Smarticles101 commented Sep 19, 2018


FileReader.readAsArrayBuffer is not implemented.

Reproducible Demo

I plan on working towards implementing this if approved.


This comment has been minimized.

Copy link

@react-native-bot react-native-bot commented Sep 19, 2018

We are automatically closing this issue because it does not appear to follow any of the provided issue templates.

Please make use of the bug report template to let us know about a reproducible bug or regression in the core React Native library.

If you'd like to propose a change or discuss a feature request, there is a repository dedicated to Discussions and Proposals you may use for this purpose.


This comment has been minimized.

Copy link

@mgscreativa mgscreativa commented Oct 3, 2018

Hi! I need readAsArrayBuffer implementation too, is there any workaround to use this with expo? I'm using expo to avoid using a mac in the development process.



This comment has been minimized.

Copy link

@AdrianoRuberto AdrianoRuberto commented May 23, 2019

I manage to make it work by using readAsDataURL:

FileReader.prototype.readAsArrayBuffer = function (blob) {
	if (this.readyState === this.LOADING) throw new Error("InvalidStateError");
	this._result = null;
	this._error = null;
	const fr = new FileReader();
	fr.onloadend = () => {
		const content = atob(fr.result.substr("data:application/octet-stream;base64,".length));
		const buffer = new ArrayBuffer(content.length);
		const view = new Uint8Array(buffer);
		view.set(Array.from(content).map(c => c.charCodeAt(0)));
		this._result = buffer;

// from:
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
const atob = (input = '') => {
	let str = input.replace(/=+$/, '');
	let output = '';

	if (str.length % 4 == 1) {
		throw new Error("'atob' failed: The string to be decoded is not correctly encoded.");
	for (let bc = 0, bs = 0, buffer, i = 0;
		buffer = str.charAt(i++);

		~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
			bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
	) {
		buffer = chars.indexOf(buffer);

	return output;

This comment has been minimized.

Copy link

@seigel seigel commented Jul 14, 2019

Is there a way to re-open this issue or do we have to create a new issue?

@facebook facebook locked as resolved and limited conversation to collaborators Sep 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
5 participants
You can’t perform that action at this time.