blset

blset

Problem with app dir using release

Hello,

it’s not clear what is the app dir with releases

I have files generated by the phoenix web app that can be downloaded.
They are stored in a directory called downs of the app dir. if I change release I expect these files to stay where they are and be found by all releases

I have added
plug Plug.Static, at: "/downs", from: Path.expand('./downs'), gzip: false
I then generate urls with /downs/xxx

1- if I run the app with mix phx.server from the app dir it works ok
2- if I run the app with _build/rel/prod/v1/bin/v1 start from the app dir (after having build the release) it works ok

the problem is :

3- if I upload the release previoulsy built (on another machine) to another directory test1 with the downs dir copied into test1 (but not in priv/static) , and from test1 I run v1/bin/v1 start, the app works ok but the files in downs are not found

I uploaded in test1 only the content of v1, not the full tree _build/prod/rel/v1

the url is correctly generated but looks like the plug static line is ignored in case 3

thanks for any advice

in short

> test1
> - downs
>    - file1
> - v2
>   - all files generated by mix release found under _build/prod/rel/v2 originally

file1 present when generating the release is found
but a file2 put by the application when running the release is not found for download although the url are exaclty similar

/downs/file1
/downs/file2

since file2 was put by the running application the app dir is ok but the download of the file intercepted by plug static works for file1 but not for file2

Marked As Solved

blset

blset

I thought it worked but in fact that does not work because at compile time

Application.get_env(:my_app, :downs_path) || Path.expand(’./downs’),

Application.get_env returns nil so you get the path of the machine which builds the release not the runtime path

I ended up with

plug Plug.Static, at: “/downs”, from: {:vf, “…/…/…/downs”},

that is a relative path which saves the need for the ENV var

Also Liked

kokolegorille

kokolegorille

Another reliable way is to use a path relative to

:code.priv_dir(:your_app)

Where Next?

Popular in Questions Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New

We're in Beta

About us Mission Statement