natewallis

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

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

Where Next?

Popular in Questions Top

siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New

Other popular topics Top

skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52238 488
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

We're in Beta

About us Mission Statement