{:ok, query} = Repo.query("SELECT photolink FROM produits")
for c <- query.rows do
{:ok, photo} = Enum.fetch(c, 0)
File.write("/tmp/#{photo}", photo, [:binary])
end
end
I want to store the file generated from File.write inside my project such as inside “/priv/uploads/file_name”
I am able to store the file inside /tmp but I have problem when I try to store the file inside another path
I have /priv/uploads inside my app but it is empty after that I do the File.write/3
I don’t understand why, I receive :ok but when I open the folders it is empty,
In general you do not want to write to priv! You should consider it as a read only artifact store.
If you need to write to a persistent location, you should manage it aside to your application, and backup it seperately.
In general the priv folder is part of your release, if you really change its content, you invalidate the integrity of your release.
Files are stored in a separete section of your filesystem or in an S3 bucket or whatever file storage backend you use, and as such has to be considered state of your application similar to your PostgreSQL database.