修复文件预览bug

This commit is contained in:
guange 2015-06-03 11:40:00 +08:00
parent 87e7db1a4b
commit 00745f1270
2 changed files with 2 additions and 2 deletions

View File

@ -71,7 +71,7 @@ class AttachmentsController < ApplicationController
if stale?(:etag => @attachment.digest) if stale?(:etag => @attachment.digest)
convered_file = File.join(Rails.root, "files", "convered_office", @attachment.disk_filename + ".html") convered_file = File.join(Rails.root, "files", "convered_office", @attachment.disk_filename + ".html")
if File.exist?(convered_file) if File.exist?(convered_file)
render :text => File.open(convered_file).read send_file convered_file, :type => 'text/html; charset=utf-8', :disposition => 'inline'
else else
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment), :type => detect_content_type(@attachment),

View File

@ -21,7 +21,7 @@ module Trustie
:open_timeout => -1 :open_timeout => -1
) )
req = resource.post :txtDes => File.new(@file, 'rb') req = resource.post :txtDes => File.new(@file, 'rb')
File.new(saved_file, "ab+") do |f| File.open(saved_file, "wb+") do |f|
f.write(req.body) f.write(req.body)
end end
return true return true