rn-fetch-blob icon indicating copy to clipboard operation
rn-fetch-blob copied to clipboard

RNFetchBlob.fs.readStream - readChunk() or similar required

Open pstanton opened this issue 7 years ago • 4 comments

I am trying to stream file data from the local file system, to another slower destination (in my case BLE).

I can't see a way to achieve this using the current API... I need to be able to request the next chunk of data when I am ready for it, which RNFetchBlobReadStream doesn't seem to allow.

I can't see how I can use onData() to serve this purpose, instead I would need to do something like the following:

let stream = await RNFetchBlob.fs.readStream(path, "base64", 512);
stream.open();
while (true) {
	let chunk = await stream.readChunk();
	if (!chunk) break;
	await send(chunk);
}

Is there a way to achieve this functionality currently? If not, I suggest adding this implementation.

pstanton avatar Aug 20 '18 03:08 pstanton

Going to need a close() as well, since the end may never be reached.

pstanton avatar Aug 20 '18 03:08 pstanton

We are open to PRs if you would like to implement this functionality

Traviskn avatar Aug 20 '18 15:08 Traviskn

@pstanton Hi Paul, Did you managed to solve your problem? I need to read lines of text one by one from a csv file and generate events myself.

omatrot avatar Nov 18 '19 16:11 omatrot

@pstanton Please change buffer size to 511 and then check it should work because in my case I changed the buffersize from 102400 to 102399 and it worked like magic!

mahesh-antroliya avatar Apr 02 '25 05:04 mahesh-antroliya