elixir - Read files in Phoenix in production mode -
i've phoenix app (i created --api flag) has additional data required process requests store in priv/data/filters.csv
.
so works fine in dev
mode, can read file like: file.stream!("priv/data/filters.csv")
, once app delivered using mix edeliver update
file not accessible anymore.
i can see folder in build directory, after app delivered there no such folder priv
. i'm not sure why it's not copied deliver folder.
what i'm doing wrong? need copy these files after deliver process? can store files have use in prod mode?
you should use :code.priv_dir/1
absolute path priv
directory of application @ runtime. work erlang releases created e.g. distillery:
file.stream!(path.join(:code.priv_dir(:my_app), "data/filters.csv"))
for me, after doing mix_env=prod mix release
, file priv/foo
copied _build/prod/lib/my_app/priv/foo
.
Comments
Post a Comment