From 9a0c4fa20b0c4082e5d995a5a783da4ae71c2319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 17 Aug 2019 11:25:43 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Resource/Fileslistitem.js | 2 +- .../react/src/modules/courses/coursesPublic/Showoldfiles.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 58305f589..706622570 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -54,7 +54,7 @@ class Fileslistitem extends Component{ }else{ let link = document.createElement('a'); document.body.appendChild(link); - link.href = "/api"+result.data.url; + link.href =result.data.url; link.download = result.data.title; //兼容火狐浏览器 let evt = document.createEvent("MouseEvents"); diff --git a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js index 1b2b89565..6b56702c3 100644 --- a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js +++ b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js @@ -189,7 +189,7 @@ class Showoldfiles extends Component{
  • {allfiles.is_pdf===false? - {allfiles.title}: + {allfiles.title}: this.showfiless(allfiles.url)} >{allfiles.title} } 当前版本 @@ -209,7 +209,7 @@ class Showoldfiles extends Component{
  • {item.is_pdf===false? - {item.title}: + {item.title}: this.showfiless(item.url)} >{item.title} }
  • From b262d98873d4b4d10dca80fef0c3554e6214f716 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 17 Aug 2019 11:25:47 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E9=99=84=E4=BB=B6=E4=B8=BApdf=E7=9A=84?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A4=E6=96=AD=EF=BC=8C=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_attachment_history.json.jbuilder | 3 ++- app/views/attachments/_attachment.json.jbuilder | 3 ++- app/views/attachments/_attachment_simple.json.jbuilder | 4 +++- app/views/attachments/_attachment_small.json.jbuilder | 4 ++-- app/views/files/histories.json.jbuilder | 8 +------- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/views/attachment_histories/_attachment_history.json.jbuilder b/app/views/attachment_histories/_attachment_history.json.jbuilder index 285aced42..6a02b569b 100644 --- a/app/views/attachment_histories/_attachment_history.json.jbuilder +++ b/app/views/attachment_histories/_attachment_history.json.jbuilder @@ -6,6 +6,7 @@ json.publish_time attachment.publish_time json.quotes attachment.quotes_count json.downloads_count attachment.downloads_count json.created_on attachment.created_on -json.url attachment_path(attachment, type: 'history').gsub("/api","") +# json.url attachment_path(attachment, type: 'history').gsub("/api","") json.is_pdf attachment.is_history_pdf? +json.url attachment.is_history_pdf? ? attachment_path(attachment, type: 'history').gsub("/api","") : attachment_path(attachment, type: 'history') json.attachment_id attachment.attachment_id diff --git a/app/views/attachments/_attachment.json.jbuilder b/app/views/attachments/_attachment.json.jbuilder index b87154157..76b9f2df0 100644 --- a/app/views/attachments/_attachment.json.jbuilder +++ b/app/views/attachments/_attachment.json.jbuilder @@ -11,6 +11,7 @@ json.quotes attachment.quotes_count json.description attachment.description json.downloads_count attachment.downloads_count json.created_on attachment.created_on -json.url download_url(attachment) +json.is_pdf attachment.is_pdf? +json.url attachment.is_pdf? ? download_url(attachment).gsub("/api","") : download_url(attachment) # json.url download_url(attachment) unless attachment.locked?(@is_member) diff --git a/app/views/attachments/_attachment_simple.json.jbuilder b/app/views/attachments/_attachment_simple.json.jbuilder index ad98fadb5..4bf6bd3e9 100644 --- a/app/views/attachments/_attachment_simple.json.jbuilder +++ b/app/views/attachments/_attachment_simple.json.jbuilder @@ -2,5 +2,7 @@ json.id attachment.id json.title attachment.title json.filesize number_to_human_size attachment.filesize json.description attachment.description -json.url download_url(attachment) +json.is_pdf attachment.is_pdf? +json.url attachment.is_pdf? ? download_url(attachment).gsub("/api","") : download_url(attachment) +# json.url download_url(attachment) json.set! :delete, delete.nil? ? true : delete if defined? delete \ No newline at end of file diff --git a/app/views/attachments/_attachment_small.json.jbuilder b/app/views/attachments/_attachment_small.json.jbuilder index 97cbee120..5a1faae3a 100644 --- a/app/views/attachments/_attachment_small.json.jbuilder +++ b/app/views/attachments/_attachment_small.json.jbuilder @@ -1,6 +1,6 @@ json.id attachment.id json.title attachment.title json.filesize number_to_human_size(attachment.filesize) -json.url download_url(attachment) +json.is_pdf attachment.is_pdf? +json.url attachment.is_pdf? ? download_url(attachment).gsub("/api","") : download_url(attachment) json.created_on attachment.created_on -json.is_pdf attachment.is_pdf? \ No newline at end of file diff --git a/app/views/files/histories.json.jbuilder b/app/views/files/histories.json.jbuilder index ed322bb17..7039752e7 100644 --- a/app/views/files/histories.json.jbuilder +++ b/app/views/files/histories.json.jbuilder @@ -1,9 +1,3 @@ -# json.partial! 'attachments/attachment_small', attachment: @file -json.id @file.id -json.title @file.title -json.filesize number_to_human_size(@file.filesize) -json.url download_url(@file).gsub("/api","") -json.created_on @file.created_on -json.is_pdf @file.is_pdf? +json.partial! 'attachments/attachment_small', attachment: @file json.partial! "attachment_histories/list", attachment_histories: @attachment_histories From b9de46e875b1cba52d559aacc3af18a5d0053818 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 17 Aug 2019 12:34:12 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E9=99=84=E4=BB=B6=E7=9A=84pdf=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E6=B7=BB=E5=8A=A0inline=E8=AF=B7=E6=B1=82=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 4 +++- app/helpers/application_helper.rb | 4 ++-- .../attachment_histories/_attachment_history.json.jbuilder | 2 +- app/views/attachments/_attachment.json.jbuilder | 2 +- app/views/attachments/_attachment_simple.json.jbuilder | 2 +- app/views/attachments/_attachment_small.json.jbuilder | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index a85937315..6202bf86d 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -15,7 +15,9 @@ class AttachmentsController < ApplicationController update_downloads(@file) redirect_to @file.cloud_url and return end - send_file(absolute_path(local_path(@file)), filename: @file.filename, type: @file.content_type.presence || 'application/octet-stream') + + pdf_attachment = params[:disposition] || "attachment" + send_file(absolute_path(local_path(@file)), filename: @file.filename,disposition: pdf_attachment, type: @file.content_type.presence || 'application/octet-stream') update_downloads(@file) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 099d45406..a5f291c7b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -257,8 +257,8 @@ module ApplicationHelper end end - def download_url attachment - attachment_path(attachment) + def download_url attachment,options={} + attachment_path(attachment,options) end # 耗时:天、小时、分、秒 diff --git a/app/views/attachment_histories/_attachment_history.json.jbuilder b/app/views/attachment_histories/_attachment_history.json.jbuilder index 6a02b569b..a2369888f 100644 --- a/app/views/attachment_histories/_attachment_history.json.jbuilder +++ b/app/views/attachment_histories/_attachment_history.json.jbuilder @@ -8,5 +8,5 @@ json.downloads_count attachment.downloads_count json.created_on attachment.created_on # json.url attachment_path(attachment, type: 'history').gsub("/api","") json.is_pdf attachment.is_history_pdf? -json.url attachment.is_history_pdf? ? attachment_path(attachment, type: 'history').gsub("/api","") : attachment_path(attachment, type: 'history') +json.url attachment.is_history_pdf? ? attachment_path(attachment, type: 'history',disposition:"inline") : attachment_path(attachment, type: 'history') json.attachment_id attachment.attachment_id diff --git a/app/views/attachments/_attachment.json.jbuilder b/app/views/attachments/_attachment.json.jbuilder index 76b9f2df0..25d7aecd0 100644 --- a/app/views/attachments/_attachment.json.jbuilder +++ b/app/views/attachments/_attachment.json.jbuilder @@ -12,6 +12,6 @@ json.description attachment.description json.downloads_count attachment.downloads_count json.created_on attachment.created_on json.is_pdf attachment.is_pdf? -json.url attachment.is_pdf? ? download_url(attachment).gsub("/api","") : download_url(attachment) +json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment) # json.url download_url(attachment) unless attachment.locked?(@is_member) diff --git a/app/views/attachments/_attachment_simple.json.jbuilder b/app/views/attachments/_attachment_simple.json.jbuilder index 4bf6bd3e9..6737838d1 100644 --- a/app/views/attachments/_attachment_simple.json.jbuilder +++ b/app/views/attachments/_attachment_simple.json.jbuilder @@ -3,6 +3,6 @@ json.title attachment.title json.filesize number_to_human_size attachment.filesize json.description attachment.description json.is_pdf attachment.is_pdf? -json.url attachment.is_pdf? ? download_url(attachment).gsub("/api","") : download_url(attachment) +json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment) # json.url download_url(attachment) json.set! :delete, delete.nil? ? true : delete if defined? delete \ No newline at end of file diff --git a/app/views/attachments/_attachment_small.json.jbuilder b/app/views/attachments/_attachment_small.json.jbuilder index 5a1faae3a..853c14b40 100644 --- a/app/views/attachments/_attachment_small.json.jbuilder +++ b/app/views/attachments/_attachment_small.json.jbuilder @@ -2,5 +2,5 @@ json.id attachment.id json.title attachment.title json.filesize number_to_human_size(attachment.filesize) json.is_pdf attachment.is_pdf? -json.url attachment.is_pdf? ? download_url(attachment).gsub("/api","") : download_url(attachment) +json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment) json.created_on attachment.created_on From 8af97d5655de723f1a2992e8bf7e75ebec49c17b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 17 Aug 2019 13:43:10 +0800 Subject: [PATCH 04/10] =?UTF-8?q?pdf=E7=9A=84=E9=A2=84=E8=A7=88=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0disposition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 6202bf86d..dde7828c5 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -17,8 +17,11 @@ class AttachmentsController < ApplicationController end pdf_attachment = params[:disposition] || "attachment" - send_file(absolute_path(local_path(@file)), filename: @file.filename,disposition: pdf_attachment, type: @file.content_type.presence || 'application/octet-stream') - + if pdf_attachment == "inline" + render pdf: absolute_path(local_path(@file)), filename: @file.filename, disposition: 'inline', type: @file.content_type.presence || 'application/octet-stream' + else + send_file(absolute_path(local_path(@file)), filename: @file.filename,stream:false, type: @file.content_type.presence || 'application/octet-stream') + end update_downloads(@file) end From 5493ca53304d4cf1963c35cee5bdf6103d7596a0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 17 Aug 2019 13:48:00 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E6=8E=A8=E8=8D=90=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 3 ++- app/views/attachments/_attachment.json.jbuilder | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 099d45406..142ca6d75 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -52,7 +52,8 @@ module ApplicationHelper shixun_id = shixun_id.blank? ? -1 : shixun_id.join(",") Shixun.select([:id, :name, :user_id, :challenges_count, :myshixuns_count, :trainee, :identifier]).where("id - in(#{shixun_id}) or homepage_show =1").unhidden.order("myshixuns_count desc, homepage_show asc").limit(3) + in(#{shixun_id})").unhidden.order("homepage_show asc, myshixuns_count desc").limit(3) + end # 相关推荐 diff --git a/app/views/attachments/_attachment.json.jbuilder b/app/views/attachments/_attachment.json.jbuilder index 01a7f4163..52f16c549 100644 --- a/app/views/attachments/_attachment.json.jbuilder +++ b/app/views/attachments/_attachment.json.jbuilder @@ -10,4 +10,4 @@ json.quotes attachment.quotes_count json.description attachment.description json.downloads_count attachment.downloads_count json.created_on attachment.created_on -json.url download_url(attachment) unless attachment.locked?(@is_member) +json.url download_url(attachment) From 8f453c4ebdc785e376e4a7f90a10cbcbaba5b329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 17 Aug 2019 13:48:01 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/Resource/Fileslistitem.js | 35 +++++-------------- .../courses/coursesPublic/Showoldfiles.js | 29 ++++++--------- public/react/src/modules/tpm/TPMIndexHOC.js | 14 +++++++- 3 files changed, 31 insertions(+), 47 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 706622570..5f7c0fa83 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -38,30 +38,13 @@ class Fileslistitem extends Component{ }).then((result)=>{ if(result.data.attachment_histories.length===0){ - if(result.data.is_pdf===true){ - this.props.ShowOnlinePdf(result.data.url) - //预览pdf - // axios({ - // method:'get', - // url:result.data.url, - // responseType: 'arraybuffer', - // }).then((result)=>{ - // var binaryData = []; - // binaryData.push(result.data); - // this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); - // window.open(this.url); - // }) - }else{ - let link = document.createElement('a'); - document.body.appendChild(link); - link.href =result.data.url; - link.download = result.data.title; - //兼容火狐浏览器 - let evt = document.createEvent("MouseEvents"); - evt.initEvent("click", false, false); - link.dispatchEvent(evt); - document.body.removeChild(link); - } + // if(result.data.is_pdf===true){ + // this.props.ShowOnlinePdf(result.data.url) + // //预览pdf + // }else{ + // + // } + this.props.DownloadFileA(result.data.title,result.data.url) }else{ this.setState({ Showoldfiles:true, @@ -146,9 +129,7 @@ class Fileslistitem extends Component{ const { checkBox, discussMessage, } = this.props; - - - + return(
    diff --git a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js index 6b56702c3..693e3448b 100644 --- a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js +++ b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js @@ -43,16 +43,6 @@ class Showoldfiles extends Component{ } showfiless=(url)=>{ - // axios({ - // method:'get', - // url:url, - // responseType: 'arraybuffer', - // }).then((result)=>{ - // var binaryData = []; - // binaryData.push(result.data); - // this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); - // window.open(this.url); - // }) this.props.ShowOnlinePdf(url) } render(){ @@ -188,10 +178,11 @@ class Showoldfiles extends Component{
  • - {allfiles.is_pdf===false? - {allfiles.title}: - this.showfiless(allfiles.url)} >{allfiles.title} - } + {allfiles.title} + {/*{allfiles.is_pdf===false?*/} + {/*{allfiles.title}:*/} + {/*this.showfiless(allfiles.url)} >{allfiles.title}*/} + {/*}*/} 当前版本
  • @@ -207,11 +198,11 @@ class Showoldfiles extends Component{
  • - - {item.is_pdf===false? - {item.title}: - this.showfiless(item.url)} >{item.title} - } + {item.title} + {/*{item.is_pdf===false?*/} + {/*{item.title}:*/} + {/*this.showfiless(item.url)} >{item.title}*/} + {/*}*/}
  • diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js index 690e8bc80..682e8f866 100644 --- a/public/react/src/modules/tpm/TPMIndexHOC.js +++ b/public/react/src/modules/tpm/TPMIndexHOC.js @@ -334,6 +334,17 @@ export function TPMIndexHOC(WrappedComponent) { window.open(this.url); }) } + DownloadFileA=(title,url)=>{ + let link = document.createElement('a'); + document.body.appendChild(link); + link.href =url; + link.download = title; + //兼容火狐浏览器 + let evt = document.createEvent("MouseEvents"); + evt.initEvent("click", false, false); + link.dispatchEvent(evt); + document.body.removeChild(link); + } render() { let{Headertop,Footerdown, isRender, AccountProfiletype}=this.state; const common = { @@ -351,7 +362,8 @@ export function TPMIndexHOC(WrappedComponent) { checkIfLogin: this.checkIfLogin, showProfileCompleteDialog: this.showProfileCompleteDialog, checkIfProfileCompleted: this.checkIfProfileCompleted, - ShowOnlinePdf:(url)=>this.ShowOnlinePdf(url) + ShowOnlinePdf:(url)=>this.ShowOnlinePdf(url), + DownloadFileA:(title,url)=>this.DownloadFileA(title,url), } return (
    From b094010ad11c5424eebee3395c238a129d947685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 17 Aug 2019 13:51:10 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Resource/Fileslistitem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 5f7c0fa83..d3405ebf5 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -129,7 +129,7 @@ class Fileslistitem extends Component{ const { checkBox, discussMessage, } = this.props; - + return(
    From e8dcb166756861f64edd9f5a487d60eb1b804bcd Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 17 Aug 2019 13:56:14 +0800 Subject: [PATCH 08/10] =?UTF-8?q?pdf=20=E9=A2=84=E8=A7=88=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index dde7828c5..7617270a8 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -18,7 +18,8 @@ class AttachmentsController < ApplicationController pdf_attachment = params[:disposition] || "attachment" if pdf_attachment == "inline" - render pdf: absolute_path(local_path(@file)), filename: @file.filename, disposition: 'inline', type: @file.content_type.presence || 'application/octet-stream' + send_data absolute_path(local_path(@file)),filename: @file.filename, disposition: 'inline',type: 'application/pdf' + # render pdf: absolute_path(local_path(@file)), filename: @file.filename, disposition: 'inline', type: @file.content_type.presence || 'application/octet-stream' else send_file(absolute_path(local_path(@file)), filename: @file.filename,stream:false, type: @file.content_type.presence || 'application/octet-stream') end From 476689314bcec5f32665fcd412de3bba975d3ed1 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 17 Aug 2019 14:00:18 +0800 Subject: [PATCH 09/10] xxx --- app/controllers/attachments_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 7617270a8..d3317e99e 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -18,8 +18,7 @@ class AttachmentsController < ApplicationController pdf_attachment = params[:disposition] || "attachment" if pdf_attachment == "inline" - send_data absolute_path(local_path(@file)),filename: @file.filename, disposition: 'inline',type: 'application/pdf' - # render pdf: absolute_path(local_path(@file)), filename: @file.filename, disposition: 'inline', type: @file.content_type.presence || 'application/octet-stream' + send_file absolute_path(local_path(@file)),filename: @file.filename, disposition: 'inline',type: 'application/pdf' else send_file(absolute_path(local_path(@file)), filename: @file.filename,stream:false, type: @file.content_type.presence || 'application/octet-stream') end From 3c1d30a133a7e56090612b7473e1e613ed720622 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 17 Aug 2019 14:03:18 +0800 Subject: [PATCH 10/10] video feature: add account check to api --- app/controllers/users/video_auths_controller.rb | 2 +- app/controllers/users/videos_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/users/video_auths_controller.rb b/app/controllers/users/video_auths_controller.rb index 0eec4dffb..a7d41bce5 100644 --- a/app/controllers/users/video_auths_controller.rb +++ b/app/controllers/users/video_auths_controller.rb @@ -1,5 +1,5 @@ class Users::VideoAuthsController < Users::BaseController - before_action :private_user_resources!, :require_auth_teacher! + before_action :private_user_resources!, :check_account, :require_auth_teacher! def create result = Videos::CreateAuthService.call(observed_user, create_params) diff --git a/app/controllers/users/videos_controller.rb b/app/controllers/users/videos_controller.rb index 1df726c0c..0ad3f87d6 100644 --- a/app/controllers/users/videos_controller.rb +++ b/app/controllers/users/videos_controller.rb @@ -1,5 +1,5 @@ class Users::VideosController < Users::BaseController - before_action :private_user_resources!, :require_auth_teacher! + before_action :private_user_resources!, :check_account, :require_auth_teacher! helper_method :current_video