将预览改为后台执行

This commit is contained in:
guange 2015-06-03 09:46:44 +08:00
parent be3680d4f3
commit 49c86eb85f
1 changed files with 3 additions and 3 deletions

View File

@ -69,9 +69,9 @@ class AttachmentsController < ApplicationController
if candown || User.current.admin? || User.current.id == @attachment.author_id
@attachment.increment_download
if stale?(:etag => @attachment.digest)
if %w[doc docx pdf].any?{|word| @attachment.diskfile.downcase.end_with? word}
req = RestClient.post 'http://192.168.80.107/Any2HtmlHandler.ashx', :txtDes => File.new(@attachment.diskfile, 'rb')
render :text => req.body
convered_file = File.join(Rails.root, "files", "convered_office", a.disk_filename + ".html")
if File.exist?(convered_file)
render :text => File.open(convered_file).read
else
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment),