Closed SpiritedDusty closed 10 years ago
Thanks for the question. There are two ways:
XmlHttpRequest
file system and use readFile
to get the item as a Buffer
.ArrayBuffer
, and then call new Buffer(data)
(a DataView
works too).Note that by default, BrowserFS will only expose Buffer
as a global if you run BrowserFS.install(window);
.
If you don't want Buffer
to be a global, then you can do the following:
// This seems insane, but in node require('buffer').Buffer === Buffer
var Buffer = BrowserFS.BFSRequire('buffer').Buffer;
// where 'data' is the ArrayBuffer containing the zip file's contents
var zipfile = new Buffer(data);
Oh I see. I'm using BrowserFS with emsceipten so I didn't have Buffer as a global. That was the thing that was throwing me off. Thanks for the help!
No problem. Let me know if you have any further questions!
In the wiki it says that ZipFS accepts a buffer for zip_data. How do I go about creating a buffer from lets say an xhr request? Theres probably an obvious answer that I'm not seeing but, I can't figure out how to make a buffer.