send_download在凤凰中未定义

时间:2017-11-11 01:04:49

标签: elixir phoenix-framework

我试图用凤凰框架创建一个api,它将pdf发送回客户端,但是我遇到了错误,说没有定义send_download。

== Compilation error in file web/controllers/test_controller.ex ==
** (CompileError) web/controllers/test_controller.ex:9: undefined function send_download/2
    (stdlib) lists.erl:1338: :lists.foreach/2
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
    (elixir) lib/kernel/parallel_compiler.ex:121: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1
MacBook-Pro-2:coetic_report_generator waynegretsky$ 

这是我使用它的实际文件(web / controllers / test_controller.ex):

defmodule CoeticReportGenerator.TestController do
  use CoeticReportGenerator.Web, :controller

  def index(conn, _params) do
    input_file = "markdown.md"
    output_file = "output/markdown_file.md"

    System.cmd("pandoc", ["-s", "-o", output_file, input_file]) 
    send_download(conn,{:file, output_file})
    #  text conn, "IT WORKS."
  end
end

这是router.ex文件:

defmodule CoeticReportGenerator.Router do
  use CoeticReportGenerator.Web, :router

  pipeline :api do
    plug :accepts, ["json", "json-api"]
  end

  scope "/api", CoeticReportGenerator do
    pipe_through :api

    get "test", TestController, :index
  end
end

当我创建它时,我使用no-html和no-brunch,以防相关。我有没有理由最终得到这个错误?当我评论它并渲染文本时,它工作正常。

0 个答案:

没有答案