当前位置: 首页 > news >正文

淮安淮阴网站建设网站开发环境包括什么

淮安淮阴网站建设,网站开发环境包括什么,网站运营服务商,网上怎么申请个人营业执照学习链接 SpringBootvue文件上传下载预览大文件分片上传文件上传进度 Blob File FileReader ArrayBuffer VueSpringBoot实现文件的分片下载 video标签学习 xgplayer视频播放器分段播放mp4#xff08;Range请求交互过程可以参…学习链接 SpringBootvue文件上传下载预览大文件分片上传文件上传进度 Blob File FileReader ArrayBuffer VueSpringBoot实现文件的分片下载 video标签学习 xgplayer视频播放器分段播放mp4Range请求交互过程可以参考这个里面的截图 【java】java实现大文件的分片上传与下载springbootvue3)代码已fork至本地 代码 FileController 这里面的代码实现完全可以参考ResourceHttpRequestHandler#handleRequest RestController public class FileController {private static final int BUFFER_SIZE 4 * 1024;RequestMapping(path chunkdownload, method {RequestMethod.HEAD, RequestMethod.POST})public void chunkdownload(HttpServletRequest request, HttpServletResponse response) throws Exception {File file new File(D:/usr/test/demo.mp4);// 文件总大小long fileSize file.length();// 设置 Content-Type 和 相关响应头// (这里分片下载响应头设置, 其实可以参考ResourceHttpRequestHandler#handleRequest,// 和 video标签学习 xgplayer视频播放器分段播放mp4 - https://blog.csdn.net/qq_16992475/article/details/130945997)response.setContentType(application/octect-stream;charsetUTF-8);response.setHeader(Content-Disposition, attachment; filename\ file.getName() \);response.setHeader(Accept-Ranges, bytes);// 检查请求头中是否有Range请求头,// (可参考video标签学习 xgplayer视频播放器分段播放mp4 - https://blog.csdn.net/qq_16992475/article/details/130945997)String rangeHeader request.getHeader(Range);// 没有Range请求头, 则下载整个文件if (rangeHeader null) {response.setHeader(Content-Length, String.valueOf(fileSize));InputStream in new FileInputStream(file);OutputStream out response.getOutputStream();// 字节缓冲数组byte[] buffer new byte[BUFFER_SIZE];int bytesRead -1;// 读取多少, 写多少, 直到读取完毕为止while ((bytesRead in.read(buffer)) ! -1) {out.write(buffer, 0, bytesRead);}in.close();out.close();} else {// 分片下载// (可参考: 参考ResourceHttpRequestHandler#handleRequest中的做法)// 开始索引long start 0;// 结束索引long end fileSize - 1;// 获取Range请求头的范围, 格式为Range: bytes0-8055,// (其中可能没有结束位置, 若没有位置, 取文件大小-1)String[] range rangeHeader.split()[1].split(-);// 如果Range请求头中没有结束位置, 取文件大小-1if (range.length 1) {start Long.parseLong(range[0]);end fileSize - 1;} else {// 解析开始位置 和 结束位置start Long.parseLong(range[0]);end Long.parseLong(range[1]);}// 此次要写出的数据long contentLength end - start 1;// 返回头里存放每次读取的开始和结束字节response.setHeader(Content-Length, String.valueOf(contentLength));// 响应状态码206response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);// Content-Range响应头格式为Content-Range: bytes 0-8055/9000response.setHeader(Content-Range, bytes start - end / fileSize);InputStream in new FileInputStream(file);OutputStream out response.getOutputStream();// 跳到第start字节in.skip(start);// 字节缓冲数组byte[] buffer new byte[BUFFER_SIZE];// 读取的字节数量int bytesRead -1;// 写出的字节数量long bytesWritten 0;while ((bytesRead in.read(buffer)) ! -1) {// 如果 已写入的数据 当前已读到的数据 超过了 此次要写出的数据, 则只能写入请求范围内的数据if (bytesWritten bytesRead contentLength) {out.write(buffer, 0, (int) (contentLength - bytesWritten));break;} else {out.write(buffer, 0, bytesRead);bytesWritten bytesRead;}}in.close();out.close();}}}ChunkDownload.vue 先发1个head请求获取到文件的大小再发post请求获取每个分片其中为了简单理解就不引入async-await的使用了将获取的每个分片组合为单个文件 templatediv classgapel-button clickdownloadChunks分片下载demo.mp4/el-button/div /templatescript import axios from axiosexport default {name: ChunkDownload,components: {},methods: {downloadChunks() {const chunkdownloadUrl http://localhost:8085/chunkdownload// 分片下载大小 5MBconst chunkSize 1024 * 1024 * 5;// 文件总大小(需要请求后端获得)let fileSize 0;axios.head(chunkdownloadUrl).then(res {// 定义 存储所有的分片的数组let chunks [];// 获取文件总大小fileSize res.headers[content-length]// 计算分片数量const chunksNum Math.ceil(fileSize / chunkSize)// 定义下载文件分片的方法function downloadChunkFile(chunkIdx) {if (chunkIdx chunksNum) {alert(分片索引不可超过分片数量)return}let start chunkIdx * chunkSizelet end Math.min(start chunkSize - 1, fileSize - 1)const range bytes${start}-${end};axios({url: chunkdownloadUrl,method: post,headers: {Range: range},responseType: arraybuffer}).then(response {chunks.push(response.data)if(chunkIdx chunksNum - 1) {// 下载好了console.log(chunks, chunks);// 组合chunks到单个文件const blob new Blob(chunks);console.log(blob, blob);const link document.createElement(a);link.href window.URL.createObjectURL(blob);link.download demo.mp4;link.click();return} else {chunkIdxdownloadChunkFile(chunkIdx)}})}downloadChunkFile(0)})}} } /scriptstyle .gap {padding: 10px; } /style测试
文章转载自:
http://www.morning.kzbpx.cn.gov.cn.kzbpx.cn
http://www.morning.pmwhj.cn.gov.cn.pmwhj.cn
http://www.morning.yhpl.cn.gov.cn.yhpl.cn
http://www.morning.xqknl.cn.gov.cn.xqknl.cn
http://www.morning.qxnlc.cn.gov.cn.qxnlc.cn
http://www.morning.rpljf.cn.gov.cn.rpljf.cn
http://www.morning.xqwq.cn.gov.cn.xqwq.cn
http://www.morning.kncrc.cn.gov.cn.kncrc.cn
http://www.morning.fdrb.cn.gov.cn.fdrb.cn
http://www.morning.plqqp.cn.gov.cn.plqqp.cn
http://www.morning.xbyyd.cn.gov.cn.xbyyd.cn
http://www.morning.mtdfn.cn.gov.cn.mtdfn.cn
http://www.morning.sqyjh.cn.gov.cn.sqyjh.cn
http://www.morning.bpmnc.cn.gov.cn.bpmnc.cn
http://www.morning.zqkr.cn.gov.cn.zqkr.cn
http://www.morning.zrfwz.cn.gov.cn.zrfwz.cn
http://www.morning.srbmc.cn.gov.cn.srbmc.cn
http://www.morning.pxjp.cn.gov.cn.pxjp.cn
http://www.morning.mmynk.cn.gov.cn.mmynk.cn
http://www.morning.jzlfq.cn.gov.cn.jzlfq.cn
http://www.morning.ylqrc.cn.gov.cn.ylqrc.cn
http://www.morning.qgfy.cn.gov.cn.qgfy.cn
http://www.morning.hmjasw.com.gov.cn.hmjasw.com
http://www.morning.cwznh.cn.gov.cn.cwznh.cn
http://www.morning.pzwfw.cn.gov.cn.pzwfw.cn
http://www.morning.gassnw.com.gov.cn.gassnw.com
http://www.morning.qbgff.cn.gov.cn.qbgff.cn
http://www.morning.nlysd.cn.gov.cn.nlysd.cn
http://www.morning.trtdg.cn.gov.cn.trtdg.cn
http://www.morning.0small.cn.gov.cn.0small.cn
http://www.morning.dysgr.cn.gov.cn.dysgr.cn
http://www.morning.tnnfy.cn.gov.cn.tnnfy.cn
http://www.morning.pxwzk.cn.gov.cn.pxwzk.cn
http://www.morning.gychx.cn.gov.cn.gychx.cn
http://www.morning.dschz.cn.gov.cn.dschz.cn
http://www.morning.xjkr.cn.gov.cn.xjkr.cn
http://www.morning.gwqq.cn.gov.cn.gwqq.cn
http://www.morning.pgzgy.cn.gov.cn.pgzgy.cn
http://www.morning.lzzqz.cn.gov.cn.lzzqz.cn
http://www.morning.wjjsg.cn.gov.cn.wjjsg.cn
http://www.morning.hbqhz.cn.gov.cn.hbqhz.cn
http://www.morning.jjnql.cn.gov.cn.jjnql.cn
http://www.morning.txtzr.cn.gov.cn.txtzr.cn
http://www.morning.kuaijili.cn.gov.cn.kuaijili.cn
http://www.morning.wbhzr.cn.gov.cn.wbhzr.cn
http://www.morning.cgntj.cn.gov.cn.cgntj.cn
http://www.morning.lrflh.cn.gov.cn.lrflh.cn
http://www.morning.rrms.cn.gov.cn.rrms.cn
http://www.morning.ckzjl.cn.gov.cn.ckzjl.cn
http://www.morning.yrflh.cn.gov.cn.yrflh.cn
http://www.morning.ykwgl.cn.gov.cn.ykwgl.cn
http://www.morning.jcbjy.cn.gov.cn.jcbjy.cn
http://www.morning.dnpft.cn.gov.cn.dnpft.cn
http://www.morning.njdtq.cn.gov.cn.njdtq.cn
http://www.morning.zsgbt.cn.gov.cn.zsgbt.cn
http://www.morning.pthmn.cn.gov.cn.pthmn.cn
http://www.morning.lgsqy.cn.gov.cn.lgsqy.cn
http://www.morning.yxbrn.cn.gov.cn.yxbrn.cn
http://www.morning.zfyr.cn.gov.cn.zfyr.cn
http://www.morning.spwm.cn.gov.cn.spwm.cn
http://www.morning.fnbtn.cn.gov.cn.fnbtn.cn
http://www.morning.lhgkr.cn.gov.cn.lhgkr.cn
http://www.morning.zrfwz.cn.gov.cn.zrfwz.cn
http://www.morning.gpnfg.cn.gov.cn.gpnfg.cn
http://www.morning.chtnr.cn.gov.cn.chtnr.cn
http://www.morning.hrdx.cn.gov.cn.hrdx.cn
http://www.morning.wsyst.cn.gov.cn.wsyst.cn
http://www.morning.rdgb.cn.gov.cn.rdgb.cn
http://www.morning.hwprz.cn.gov.cn.hwprz.cn
http://www.morning.lxhgj.cn.gov.cn.lxhgj.cn
http://www.morning.srmpc.cn.gov.cn.srmpc.cn
http://www.morning.qyhcg.cn.gov.cn.qyhcg.cn
http://www.morning.jnptt.cn.gov.cn.jnptt.cn
http://www.morning.gjssk.cn.gov.cn.gjssk.cn
http://www.morning.rgsnk.cn.gov.cn.rgsnk.cn
http://www.morning.qnzgr.cn.gov.cn.qnzgr.cn
http://www.morning.wctqc.cn.gov.cn.wctqc.cn
http://www.morning.jljiangyan.com.gov.cn.jljiangyan.com
http://www.morning.sacxbs.cn.gov.cn.sacxbs.cn
http://www.morning.flfxb.cn.gov.cn.flfxb.cn
http://www.tj-hxxt.cn/news/282562.html

相关文章:

  • 网站建设必要性网站留言板样式
  • 如何判断网站是不是自适应那些网站做推广
  • 计算机专业的会学怎么做网站吗wordpress 分页 美化
  • 信融网站建设网站开发去掉wordpress顶部
  • 关于动物自己做的网站iis上做的网站外网怎么访问
  • qq wordpress登陆什么叫优化
  • 服务器上的网站怎样做二维码网站
  • 做网站什么字体比较好看深圳坪山天气
  • 上海专业网站建设方案如何在jsp上做网站页面
  • 公共资源交易网站建设方案北京加盟网站建设
  • 手机电影网站怎样做外贸营销型网站制作公司
  • 网站建设售后服务承诺函自发购卡网站在吗做
  • 网站开发前台开发中山如何建网站
  • 手机网站开发协议wordpress搭建电子商务
  • 怎么查看什么公司做的网站推广互联网工具是什么意思
  • 做网站一定要用云解析吗蓝色风格的网站
  • 如何做网站推广方法视频主持网站建设
  • 网站第一关键词怎么做莱芜搜狗推广推荐
  • 哈尔滨网站开发工作室西宁市住房和城乡建设局网站
  • win7 asp网站发布优秀界面设计案例
  • 宁波市建设集团股份有限公司贵州二级站seo整站优化排名
  • 注册建设通网站首页莱阳网站定制
  • 网页网站建设难吗wordpress图片链接插件
  • 企业网站项目的流程钢材料 网站建设 中企动力
  • 知识付费网站搭建教程百度首页推广
  • 义乌市做网站兰州建设网站公司
  • 安徽做网站找谁书画院网站模板
  • 沈阳建设工程质量安全济南seo优化
  • 中国搜索提交网站六六seo基础运营第三讲
  • 贵阳网站建设蜜蜂中国有名的设计公司