【问题标题】:Ruby on Rails - send_file is not workingRuby on Rails - send_file 不工作
【发布时间】:2014-01-05 11:35:57
【问题描述】:

我写了以下代码。

def help_doc
  pdf_filename = File.join(Rails.root, "/public/doc.pdf")
  send_file(pdf_filename, :filename => "doc.pdf" :type => "application/pdf", :diposition => "inline")
end

它正在工作,但不是我想要的。我想在浏览器中查看 pdf,但它正在下载文档。

我以为只要写:disposition => "inline"就可以在浏览器上看到pdf了。

【问题讨论】:

  • :type 选项前缺少逗号。这是一个错字还是你的代码?

标签: ruby-on-rails inline sendfile


【解决方案1】:

尝试删除内容处置。您的代码(沉积与处置)中有错字,并且文件名后缺少逗号。

【讨论】:

  • 这只是一个错误,当我写这个问题时。在我的代码中,是正确的,但保持错误。
  • send_file 实际上并没有很好地工作
猜你喜欢
  • 2023-04-08
  • 2012-01-29
  • 2014-06-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多