i learnt ex_file . Looks like exfile_path doesnt take @conn use that. You should learn how to debug a elixir app.
<%= link âDownloadâ, to: download_path(@conn, :download, file_path: exfile_path(@user.img)) %>
i learnt ex_file . Looks like exfile_path doesnt take @conn use that. You should learn how to debug a elixir app.
<%= link âDownloadâ, to: download_path(@conn, :download, file_path: exfile_path(@user.img)) %>
Great, thanks for your help. It still generates errors
== Compilation error in file lib/hello_web/views/user_view.ex ==
** (SyntaxError) lib/hello_web/templates/user/show.html.eex:7: unexpected token: ââÂÂâ (column 7, codepoint U+201C)
(eex) lib/eex/compiler.ex:45: EEx.Compiler.generate_buffer/4
(phoenix) lib/phoenix/template.ex:378: Phoenix.Template.compile/2
(phoenix) lib/phoenix/template.ex:186: anonymous fn/3 in Phoenix.Template.âMACRO-before_compileâ/2
(elixir) lib/enum.ex:1899: Enum.â-reduce/3-lists^foldl/2-0-â/3
(phoenix) expanding macro: Phoenix.Template.before_compile/1
lib/hello_web/views/user_view.ex:1: HelloWeb.UserView (module)
(elixir) lib/kernel/parallel_compiler.ex:198: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6
again what is output of that
<%= exfile_path(@user.img) %>
It works, again it shows the text
/attachments/gwrkO8vdfVYJN8tK_hHtnL2yBVPnGhl4PjJRNOd_YDs=/cache/8a0cf98bf70e488e2d3ced494f5858be18f8ee728176b686fbb6b678e8f2/file
you should learn more elixir and disable encrypt. These codes should work. Your path looks right
I will keep trying, thank you for your time.
last thing try that
<%= link âDownloadâ, to: download_path(@conn, :download, file_path: "#{exfile_path(@user.img)}") %>
It produced error.
== Compilation error in file lib/hello_web/views/user_view.ex ==
** (SyntaxError) lib/hello_web/templates/user/show.html.eex:7: unexpected token: "âÂÂ" (column 7, codepoint U+201C)
(eex) lib/eex/compiler.ex:45: EEx.Compiler.generate_buffer/4
(phoenix) lib/phoenix/template.ex:378: Phoenix.Template.compile/2
(phoenix) lib/phoenix/template.ex:186: anonymous fn/3 in Phoenix.Template."MACRO-__before_compile__"/2
(elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix) expanding macro: Phoenix.Template.__before_compile__/1
lib/hello_web/views/user_view.ex:1: HelloWeb.UserView (module)
(elixir) lib/kernel/parallel_compiler.ex:198: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6
i didnt understand what is that error. But doesnt look like about link. Error at line 7 in your show.html.eex
Downlaod should be yellor instead of green. Manually change double quotes yourself. Looks like forum changes double quotes
Thank you very much, this way it worked <%= link Download, to: download_path(@conn, :download, file_path: exfile_path(@user.img)) %>
Now Iâm going to try to take the url dynamically in the controller
With the help of @dokuzbir the application downloads files. When they are downloaded, they are not readable.
Steps to get to this point:
create a test application
mix phx.new hello
Edit the mix.
in application
: exfile,: exfile_imagemagick
in deps
{: exfile, "~> 0.3.6"},
{: exfile_imagemagick, "~> 0.1.2"}
mix phx.gen.html Accounts User users img: string name: string \ username: string: unique
Add on the route
forward "/ attachments", Exfile.Router
get "/ download", DownloadController,: download
Create controller
defmodule HelloWeb.DownloadController do
import Exfile.Ecto.CastContentType
import Exfile.Ecto.CastFilename
use HelloWeb, :controller
def download(conn, %{âfile_pathâ => file_path}) do
conn
IO.inspect file_path
|> put_resp_header(âcontent-dispositionâ, âattachment; filename=âtest-file.jpgââ)
|> send_resp(200, file_path)
end
end
Add in the template show.html
<% = link Download, to: download_path (@conn,: download, file_path: exfile_path (@ user.img))%>
Now Iâm trying to make the downloaded files readable
FYI, double quotes are modified inside blockquote, but not inside code
Here is code starting with ```elixir
"this is ok"
Here is a blockquote, and double quotes are modifiedâŚ
âthis is not okâ
Thank you!