From 49c86eb85fb6d8872ba0050d352e545f33381525 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 3 Jun 2015 09:46:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E9=A2=84=E8=A7=88=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 68d83f974..f7adf802b 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -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),