【发布时间】:2015-12-11 17:22:47
【问题描述】:
我正在尝试将文件下载拆分为后台进程。我的资产存储在 S3 上。
我的原始(阻塞)代码如下所示
# From DownloadsController#download
data = open(path)
send_data(data.read, type: @download.mime_type, filename: @download.file_title)
所以我设置了Redis和Sidekiq,并创建了FielDownloadWorker:
class FileDownloadWorker
include Sidekiq::Worker
def perform(path, mime_type, file_title)
data = open(path)
# What happens next?
end
end
调用方式:
FileDownloadWorker.perform_async(路径,@download.mime_type,@download.file_title)
如何从工作器启动下载?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 download resque worker