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

Tee
can someone please explain to me how Enum.reduce works with maps
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
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
RisingFromAshes
I've read in another post that it may be possible with a router helper - but I couldn't find an appropriate one, and tbh, I'm still just ...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "eq...
New
vegabook
I'm brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53578 245
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I fore...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement