Upload files to exrm release

I use the html file as a template with the following code working in dev mode (not in exrm release):

{:ok, template} = File.read "priv/static/templates/receipt_template.html" 

When a release is packaged using exrm, this relative path is no longer valid and the file cannot be found. Is there a better way to declare a path so that it doesn't get messed up when it turns into an issue?

+6
source share
1 answer

Use Path.join("#{:code.priv_dir(:your_app_name)}", "static/templates/receipt_template.html") to get the correct path. I would recommend always using this because it is guaranteed to work regardless of environment.

+7
source

All Articles