项目要求某些资产不能公开访问,所以我通过AssetsController提供服务,如下所示:
def show
asset = Asset.find(params[:id])
unless Article.viewable_by(current_user).find_by_id(asset.attachable_id).nil?
send_file asset.data.path(style = params[:style]), :type => asset.data_content_type, :disposition => 'inline' #THIS
else
head(:forbidden) and return
end
end
适用于图像。视频无法在浏览器中播放。它们在公共场合服务时工作正常。
以下是一些截图(拉动资源,Chrome开发者工具上的网络标签已打开)
工作(播放,仍然看到已取消的请求)
断
以下是Apache对此的评论:
[ pid=2796 thr=140722427586528 file=ext/apache2/Hooks.cpp:784 time=2011-12-06 21:36:57.803 ]: Either the vistor clicked on the 'Stop' button in the web browser, or the visitor's connection has stalled and couldn't receive the data that Apache is sending to it. A$
我做了两个请求,并为每个请求获得了几个。
有什么想法吗?