FileReader icon indicating copy to clipboard operation
FileReader copied to clipboard

Newlines are inserted every 76 characters

Open kylemacfarlane opened this issue 11 years ago • 0 comments

When you read files in browsers with native support for FileReader then the result is one long string. However when using this polyfill newlines are inserted every 76 characters. This doesn't seem to make any difference when reading images but zip files read this way will not work with zip.js.

While base64 is meant to have a newline every 64 or 76 characters, what we're actually dealing with here are data URIs which are meant to be a single line.

To work around this issue I'm currently just replacing all whitespace in the result with .replace(/\s/gm, '').

kylemacfarlane avatar Aug 03 '12 23:08 kylemacfarlane