- Add
ihp-zip
andzip-archive
to thehaskellDeps
in yourdefault.nix
:let ... haskellEnv = import "${ihp}/NixSupport/default.nix" { ihp = ihp; haskellDeps = p: with p; [ # ... ihp-zip zip-archive ]; ...
- Run
make -B .envrc
- Add
IHP.Zip.ControllerFunctions
to yourWeb.Controller.Prelude
:module Web.Controller.Prelude ( module Web.Types , module Application.Helper.Controller , module IHP.ControllerPrelude , module Generated.Types , IHP.Zip.ControllerFunctions -- <------- ADD THIS EXPORT ) where import Web.Types import Application.Helper.Controller import IHP.ControllerPrelude import Generated.Types import IHP.Zip.ControllerFunctions -- <----- ADD THIS IMPORT
In your action use it like this:
module Web.Controller.Users where
import Web.Controller.Prelude
import qualified Codec.Archive.Zip as Zip
instance Controller UsersController where
action ExportAction = do
archive <- ["FileA", "FileB"]
|> Zip.addFilesToArchive [] Zip.emptyArchive
renderZip "Export.zip" archive