natewallis
Creating an in memory zip file
Hi there,
My application is related to the creation of educational content and I have added a route to my application that is reponsible for creating an in-memory zip file that contains the necessary files for a SCORM 1.2 package for loading into LMS platforms.
I have experience with SCORM packages (as boring and mundane as they are) and I have started playing with the erlang :zip module to create my in memory zip file which is then sent on to the users browser.
However, I am not sure which area of elixir I should be looking in when it comes to creating the in-memory files that are used to generate my module. For example, one of the files in the SCORM package is a simple HTML file that includes an IFRAME to content in my application.
Whats the neatest and most readable way to create this HTML file in-memory? I was thinking Phoenix.View.render_to_iodata but then wasn’t sure of the implications of including templates in my templates directory that aren’t used by any views that are accessible via URL…
Most Liked
jozef
I’ve had a similar problem to solve. Create a zip file in memory from bunch of files that I had content in strings. And then base64 it. The safest way is to use zip module from erlang. Theres a create method that takes filename, list of files and options where you can pass that you wanna work in memory. This is what I came up with.
{:ok, {_filename, data}} = :zip.create("extension.zip", [{'file1.txt', "content of file 1"}, {'file2.txt',"content of file 2"}], [:memory])
data |> Base.encode64








