- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 Rails 3 应用程序需要生成图像并将数据发送到浏览器。
该应用程序必须部署在 Heroku 上。
然而,Heroku 只支持通过 Mongrel 进行流式传输,它保留了内存。然后这会导致 Heroku 变慢,然后在十几个请求后终止线程。
https://devcenter.heroku.com/articles/error-codes#r14-memory-quota-exceeded
我目前正在使用来自 ActionController::DataStreaming 的 send_data 或 send_file
http://api.rubyonrails.org/classes/ActionController/DataStreaming.html#method-i-send_data
Heroku 不支持 Rack::Sendfile 或 x-sendfile。
https://devcenter.heroku.com/articles/rack-sendfile
“ruby-mongrel-x-sendfile”项目说:“通过 mongrel 流式传输大量数据是一件坏事;会引发严重的内存泄漏”并提供“in-mongrel 解决方案”。但这看起来不是一个好的解决方案。
http://code.google.com/p/ruby-mongrel-x-sendfile/
一个缓慢的解决方案是先将每个文件上传到 Amazon S3。
请问有人有什么想法吗?
最佳答案
答案是开始垃圾收集:
GC.start
关于ruby-on-rails - 如何在 Heroku 上使用 send_file(或 send_data)解决内存泄漏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12068680/
#in my controller (works just fine) order = Order.find(params[:id]) url = order.receipt.file
我似乎无法通过这个测试,我不明白为什么。 controller_spec.rb: require 'rails_helper' RSpec.describe QuotationRequestsCont
我正在使用 rails 3.2.22.4 和 ruby 2.2.4。我正在测试 send_file 功能。我在服务器日志中收到“文件已发送”,但我看不到它正在浏览器中下载。单击保存按钮将调用此操作
我正在构建一个 Rails 应用程序(5.0.4,Ruby 2.3.3),它使用 Prawn 创建一个 PDF 文件,并使用 ActionController 的 send_data 将其发送给用户,
我的 Controller 中有一个使用 send_data 的方法,如下所示: def show expires_in 10.hours, :public => true send_data
我正在开发一个代码库,我需要允许用户下载已经驻留在 AWS S3 上的 PDF 文档。我已经实现了一个用于先前功能的下载问题。 对于此功能,我需要在用户完成文件下载后更新 UI(进度步进器)。我最初认
我正在为微 Controller 编写 uart 代码。我的代码在传递 string("...") 时工作正常,但是当我尝试传递 char('.') 时出现问题。是的,我已经将“s”声明为字符串指
我有一个 Rails 应用程序,允许用户下载生成的 CSV 文件。下载文件后,我想将用户重定向到新的 URL 或操作。在 send_data 之后是否有重定向的技巧? 我想做这样的事情(这不起作用):
我在 html.erb 中使用以下标签来显示和下载不在 public/images 文件夹中的 jpg 文件: 我的 Controller 代码如下: def retrieve @photo
如何在 Rails 中测试 send_data 方法? 最佳答案 首先看一下send_data方法的源码http://api.rubyonrails.org/classes/ActionControl
美好的一天!我想下载自动生成的文件 qwerty.csv,但它仅返回文本“12345”(没有文件)。你能帮我吗? 用户界面 function getCsv() { var ids = get
我有一个连接到 Rails API 后端的 VueJS 前端。 在其中一个端点中,我正在使用 WickedPDF生成 PDF。当我在浏览器中打开 URL 本身时,PDF 可以正常下载并且完全按照预期工
在 Controller 中我有: send_data(data, filename: "payment_file") 在我看来: 但它总是内联显示文件的内容。有人可以帮我吗? 最佳答案 我明白了
我在 Controller 中有一个函数,它接受一些规范并生成有关它们的报告。这个函数 user_report 在 View 中被调用: { :controller => :reports, :ac
我有一个简单的 Rails 应用程序,可以从(私有(private))S3 存储桶下载 PDF 并将其提供给浏览器。 # app/controllers/file_controller.rb clas
我在报告 Controller 中使用此代码动态创建 csv 文件: def exportCsv @report = Report.find(:all) csv = CSV.ge
我使用 ruby 1.9.3 和 redmine 1.4.4 据此-> Please help me send a jpg file using send_data ,我在 Controller
使用 RSpec 测试以下代码的最佳方法是什么?我应该测试什么? show 操作打开一个文件并流式传输它。此外,如果该操作依赖于某处存在的文件,我可以对其进行测试吗? def show image
我正在尝试使用 send_data 返回 PNG 图像作为 ajax post 请求的响应。如何让浏览器在成功回调时触发下载? 详细信息 我使用 canvas.toDataURL() 生成一个大型 B
我使用以下代码在客户端浏览器中发送或下载文件。在我刷新页面时单击链接后,这在所有浏览器中都可以正常工作,但在 safari 中却使我的 session 为零。 def export_csv csv =
我是一名优秀的程序员,十分优秀!