预览时,下载次数不累加
This commit is contained in:
parent
7a9b5712c0
commit
4aeac1bd64
|
@ -68,6 +68,7 @@ class AttachmentsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def direct_download
|
def direct_download
|
||||||
|
@attachment.increment_download
|
||||||
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
|
||||||
|
@ -78,7 +79,6 @@ class AttachmentsController < ApplicationController
|
||||||
# 下载添加权限设置
|
# 下载添加权限设置
|
||||||
candown = attachment_candown @attachment
|
candown = attachment_candown @attachment
|
||||||
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
|
|
||||||
if stale?(:etag => @attachment.digest)
|
if stale?(:etag => @attachment.digest)
|
||||||
if params[:preview] == 'true'
|
if params[:preview] == 'true'
|
||||||
convered_file = @attachment.diskfile
|
convered_file = @attachment.diskfile
|
||||||
|
|
Loading…
Reference in New Issue