LightMind commented on issue #364:
URL:
https://github.com/apache/cordova-plugin-file/issues/364#issuecomment-774216222
I have managed to change FileWriter, such that it can convert ArrayBuffers
to base64 encoded strings itself.
To get the correct base64 encoded string, it is important to call
`FileReader.readAsDataURL` in the right way;
```
fileReader.readAsDataURL(
new Blob([arrayBuffer], {
type: 'application/octet-binary'
})
);
```
Otherwise you would encode the string representation of the ArrayBuffer,
which is not at all what you want.
[Link to the changed
file](https://github.com/LightMind/cordova-plugin-file/blob/master/www/FileWriter.js)
I have used this to write 1MiB and smaller files, and the performance looks
better for now. Especially the memory usage for each file or chunk is only
about twice the filesize/chunksize. There is less garbage collection happening.
I will test this with bigger files and measure the timing in comparison to
the original version, to see if it actually performs better, and implement
chunking, if that seems necessary.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]