Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_video
cxt 5 years ago
commit a76a558da3

@ -17,9 +17,11 @@ class AttachmentsController < ApplicationController
redirect_to @file.cloud_url and return
end
pdf_attachment = params[:disposition] || "attachment"
if pdf_attachment == "inline"
type_attachment = params[:disposition] || "attachment"
if type_attachment == "inline"
send_file absolute_path(local_path(@file)),filename: @file.title, disposition: 'inline',type: 'application/pdf'
elsif type_attachment == "MP4"
send_file_with_range absolute_path(local_path(@file)), disposition: 'inline', type: "video/mp4", range: true
else
send_file(absolute_path(local_path(@file)), filename: @file.title,stream:false, type: @file.content_type.presence || 'application/octet-stream')
end
@ -202,4 +204,31 @@ class AttachmentsController < ApplicationController
end
end
def send_file_with_range(path, options = {})
logger.info("########request.headers: #{request.headers}")
logger.info("########request.headers: #{File.exist?(path)}")
if File.exist?(path)
size = File.size(path)
logger.info("########request.headers: #{request.headers}")
if !request.headers["Range"]
status_code = 200 # 200 OK
offset = 0
length = File.size(path)
else
status_code = 206 # 206 Partial Content
bytes = Rack::Utils.byte_ranges(request.headers, size)[0]
offset = bytes.begin
length = bytes.end - bytes.begin
end
response.header["Accept-Ranges"] = "bytes"
response.header["Content-Range"] = "bytes #{bytes.begin}-#{bytes.end}/#{size}" if bytes
response.header["status"] = status_code
send_data IO.binread(path, length, offset), options
else
raise ActionController::MissingFile, "Cannot read file #{path}."
end
end
end

@ -1,5 +1,5 @@
import React,{ Component } from "react";
import { WordsBtn,ActionBtn,getmyUrl } from 'educoder';
import { WordsBtn,ActionBtn,getmyUrl,getUrl } from 'educoder';
import {Tooltip,message,Input, Button} from 'antd';
import {Link} from 'react-router-dom';
import axios from 'axios'
@ -60,7 +60,8 @@ class Fileslistitem extends Component{
if(list.content_type==="video/mp4"){
this.setState({
videoModalObj:true,
file_url:getmyUrl(list.url+'?file_name='+list.title),
file_url:"https://"+document.domain+list.url+'?file_name='+list.title+"&disposition=MP4",
// file_url:getUrl()+list.url+'?file_name='+list.title+'&disposition=MP4',
})
return
}else{
@ -92,7 +93,9 @@ class Fileslistitem extends Component{
if(list.content_type==="video/mp4"){
this.setState({
videoModalObj:true,
file_url:getmyUrl(list.url+'?file_name='+list.title),
file_url:"https://"+document.domain+list.url+'?file_name='+list.title+'&disposition=MP4',
// file_url:getUrl()+list.url+'?file_name='+list.title+'&disposition=MP4',
})
return
}else{
@ -127,9 +130,10 @@ class Fileslistitem extends Component{
Clicktobroadcastthevideo=(bool,url)=>{
this.setState({
videoModalObj:bool,
file_url:getmyUrl(url),
})
videoModalObj:bool,
file_url:"https://"+document.domain+url+'&disposition=MP4',
// file_url:getUrl()+url+'&disposition=MP4',
})
}
@ -215,8 +219,11 @@ class Fileslistitem extends Component{
const { checkBox,
discussMessage,index
} = this.props;
console.log("Fileslistitem");
console.log(file_url);
// console.log("Fileslistitem");
// console.log( document.domain);
// console.log(this.props.imhost);
// console.log( window.location.href);
return(
<div className="graduateTopicList boardsList">
{
@ -228,16 +235,16 @@ class Fileslistitem extends Component{
width={800 - 1}
>
<video
autoplay="true"
src={file_url} controls="true" controlslist="nodownload">
preload="auto"
src={file_url} controls="true" >
您的浏览器不支持 video 标签
</video>
{/*<div className="df copyLine">*/}
{/* <Input value={file_url}*/}
{/* className="dark"*/}
{/* ></Input>*/}
{/* <ActionBtn className="copybtn" data-clipboard-text={file_url} onClick={() =>this.copyurls()}>复制视频地址</ActionBtn>*/}
{/*</div>*/}
<div className="df copyLine">
<Input value={file_url}
className="dark"
></Input>
<ActionBtn className="copybtn" data-clipboard-text={file_url} onClick={() =>this.copyurls()}>复制视频地址</ActionBtn>
</div>
</HeadlessModal>
:""
@ -256,7 +263,7 @@ class Fileslistitem extends Component{
{...this.props}
visible={this.state.Showoldfiles}
allfiles={this.state.allfiles}
Clicktobroadcastthevideo={(bool,urls)=>this.Clicktobroadcastthevideo(bool,urls)}
Clicktobroadcastthevideo={(bool,urls,index)=>this.Clicktobroadcastthevideo(bool,urls,index)}
closaoldfilesprops={this.closaoldfilesprops}
/>
<style>{`

@ -1,6 +1,6 @@
import React,{ Component } from "react";
import { Input, Checkbox, Table, Tooltip, Pagination,Spin } from "antd";
import { WordsBtn,on, off, trigger } from 'educoder';
import { WordsBtn,on, off, trigger ,getUrl} from 'educoder';
import axios from 'axios';
import Modals from '../../modals/Modals';
import Sendtofilesmodal from "../coursesPublic/SendToFilesModal";
@ -15,7 +15,6 @@ import _ from 'lodash'
import './style.css';
import '../css/members.css';
import moment from 'moment';
class Fileslists extends Component{
constructor(props){
super(props);

@ -49,6 +49,9 @@ class Showoldfiles extends Component{
isaboxonClick=(item)=>{
this.props.Clicktobroadcastthevideo(true,item.url+'&file_name='+item.title);
}
isaboxonClicks=(item)=>{
this.props.Clicktobroadcastthevideo(true,item.url+'?file_name='+item.title);
}
render(){
let {visible,allfiles}=this.props;
@ -188,7 +191,7 @@ class Showoldfiles extends Component{
{
allfiles&&allfiles.content_type&&allfiles.content_type==="video/mp4"?
<a className={"isabox"} target="_blank" onClick={()=>this.isaboxonClick(allfiles)}>{allfiles.title}</a>
<a className={"isabox"} target="_blank" onClick={()=>this.isaboxonClicks(allfiles)}>{allfiles.title}</a>
:
<a className={"isabox"} href={allfiles.url} target="_blank" >{allfiles.title}</a>
}

Loading…
Cancel
Save