Skip to content

Instantly share code, notes, and snippets.

@olivermt olivermt/bug.ex
Created Mar 2, 2017

Embed
What would you like to do?
#This works in iex console:
:zip.create('c:/Users/oliver/AppData/Local/Temp/5f18ffe7-f925-47e7-8583-3f16a1acdf01/bundle.zip',['c:/Users/oliver/AppData/Local/Temp/5f18ffe7-f925-47e7-8583-3f16a1acdf01/2-cutedog.jpg'])
#This does not work from a Task:
zip_files = Enum.map(files, fn %{"id" => id, "name" => name} ->
Path.join(dest_dir, "#{id}-#{name}")
end)
|> Enum.map(&String.to_char_list/1)
zip_target = Path.join(dest_dir, "bundle.zip") |> String.to_char_list
Logger.debug "Zipping files #{inspect zip_files} to #{inspect zip_target}"
zip_ret = :zip.create(zip_target, files)
Logger.debug "Zip return: #{inspect zip_ret}"
#This is the output
Zipping files ['c:/Users/oliver/AppData/Local/Temp/94ae7500-4850-49d9-a6b2-555ffd96c150/2-cutedog.jpg'] to 'c:/Users/oliver/AppData/Local/Temp/94ae7500-4850-49d9-a6b2-555ffd96c150/bundle.zip'
[debug] module=Sow.OSPApplicationExportService function=files/2 Zip return: {:error, :einval}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.