支持doc docx pdf
This commit is contained in:
parent
b3abf610d9
commit
be3680d4f3
|
@ -69,12 +69,14 @@ class AttachmentsController < ApplicationController
|
||||||
if candown || User.current.admin? || User.current.id == @attachment.author_id
|
if candown || User.current.admin? || User.current.id == @attachment.author_id
|
||||||
@attachment.increment_download
|
@attachment.increment_download
|
||||||
if stale?(:etag => @attachment.digest)
|
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')
|
req = RestClient.post 'http://192.168.80.107/Any2HtmlHandler.ashx', :txtDes => File.new(@attachment.diskfile, 'rb')
|
||||||
render :text => req.body
|
render :text => req.body
|
||||||
|
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),
|
||||||
# :disposition => 'attachment' #inline can open in browser
|
:disposition => 'attachment' #inline can open in browser
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue