Storing and accessing multiple files within a single file (like a database, or like a word file)


Hey Guys,

This might be a silly question, i really have no way to explain this better. So let me have a go at this.

So, i want to hypothetically write a Electron app, that opens when a file is double clicked. Lets say for sake of argument, its a rich text editor (like Microsoft Word). So, once a user double clicks any “.rtxt” file (lets say rtxt is the file extension i created specifically for my app), it will be opened automatically from my app. Alright, so the basics are out of the way. Lets talk about how to create the rtxt file.

Lets say a user wants to add an image to this rich text file, a video, styles etc. Lets say i render the rich text using html, i store styles as css and store images as images (rather than links to existing files on the users hdd). How will i then create a myfile.rtxt that contains all that information (having all the dependencies self contained within it)? Obviously i could store/render images etc with some base64 encoded string, but is there a better way? Is there some way that i could sort of create the .rtxt file as a zipped up folder and essentially store multiple files within this folder (ie. separate image files, data file for the main html, css file for stylings), yet only showing a single .rtxt file for the end users?

Obviously some of you might suggest to treat rtxt file as a data file (say json file) and convert all data into data strings and store them all in the one file. I guess this is fair, is there any pre-made easy tools for this? Anyway, that means, when the file is being run, all assets that were stored within the file will need to come into memory instead of just fetching the file when you need it (lets say a video, you only want to play the video when the user clicks on it, not when they just double click the file).

If this can be achieved, could someone direct me to some resources? any node modules/tools i can use?

Also, i prefer if this can be achieved cross platform (windows/linux/mac).

Ty in advance


This isn’t really an Electron question, but more of a general how-to question. You may want to look at the file formats for Microsoft Word or Open Office. There are a number of different approaches for how to do this. They’re all pretty complex and a rather large undertaking in themselves. The simplest would just be to create a zip file with everything in it in some sort of virtual file-system.


Thanks for that. That gives me some direction. I posted here not because this is an electron problem, but since this is a scenario that other electron users might be in (writing node based desktop code), so there would likely be people here that might have some insight (or atleast might like to know in the future).

I will do some more research. You atleast gave me some key words i can search for, and thank you for that. If you or anyone have any more insight, suggestions, instructions or simply some recommendations of node modules that can handle such thing, please do post them here as it will not only help me but others in the future. :smiley:


@decay have you found a solution for this yet? I am in this exact situation right now…
I going with the whole zip file format, but unfortunately the only library I could find supporting that (adm-zip) is completely broken and unusable…
@leedohm do you happen to have any pointers to ressources regarding reading and writing from zip-files without having to unzip them in electron?