Created
March 2, 2017 16:21
-
-
Save olivermt/399796f2aa2b751fcc97b35ffd828104 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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