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

网站的标题符号备案域名交易平台

网站的标题符号,备案域名交易平台,厦门电商网站,wordpress主题破解版文件服务使用 minio,使用 nginx 反向代理。 将文件存放在 minio 上,如果是公开的文件,则统一放到一个桶,设置为公开只读。 如果是私有文件,则使用临时链接,给有权限的用户查看和打印。 要实现在 html 页…

文件服务使用 minio,使用 nginx 反向代理。

将文件存放在 minio 上,如果是公开的文件,则统一放到一个桶,设置为公开只读。

如果是私有文件,则使用临时链接,给有权限的用户查看和打印。

要实现在 html 页面上,弹框显示 pdf 和打印。

遇到问题:

问题 1 跨域安全问题,浏览器不允许加载

由于我的某个主页面上加了安全标签(<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">),导致报错:“Failed to load resource: net::ERR_CONNECTION_RESET”, 请求头出现警告信息:"Provisional headers are shown Learn more"

demo 页面就可以正常下载文件,排查了好久才发现是安全标签的问题。

问题 2 显示 pdf 文件

从后端把 minio 中的 pdf 文件链接(使用 minio 的客户端生产的临时链接)返回给前端,但是 浏览一直不显示文件,直接就下载了保存到了本地,使用 embed 标签或者 iframe 都不行。以为是 nginx 问题,不管如何配置,都不行。后来使用 pdf.js 来处理,果然可以显示 pdf 文件。

问题 3 打印 pdf 文件。

打印 pdf ,并没有达到效果,打印的竟然是网页页面,折腾了好久,都不能实现打印 pdf 原文件。

最后决定后端把 pdf 文件下载到 tomcat 的目录,再把这个 tomcat 中的文件链接返回给前端。使用 spring 的 restTemplate 来下载文件(临时链接),结果遇到 403 ,真奇怪。不管我如何处理,始终报 403。后面参考(设置 user agent)了别人的做法,终于可以下载了。

String u = URLDecoder.decode(addr, StandardCharsets.UTF_8.name());URL url = new URL(u);HttpURLConnection connection = ((HttpURLConnection)url.openConnection());connection.addRequestProperty("User-Agent", "Mozilla/4.0"); // 这里是用来处理 403 错误的。InputStream input = null;try {if (connection.getResponseCode() == 200) {Map<String, List<String>> headerFields = connection.getHeaderFields();headerFields.forEach((key,list)->{if (key != null) {response.setHeader(key, list.get(0));}});input = connection.getInputStream();// 文件流复制/转发StreamUtils.copy(input, response.getOutputStream());} else {input = connection.getErrorStream();}} finally {try {input.close();} catch (Exception e) {}}

后来我一想,直接新开文件下载接口,把 pdf 文件下载文件流直接转发给前端 iframe ,看看如何。 结果成功显示并且还可以打印。此时我并没设置 Content-Type 返回头 header。让我顿然开朗,马上检查在 minio 中的文件的 content type 为 application/octet-stream ,不是 pdf 类型。原来文件上传到 minio 时没有处理好文件类型。导致下载文件时,浏览器直接把文件下载。处理好后,重新上传 pdf 文件,文件类型为 application/pdf。在文件下载文件流转发给前端时,把下载时返回 header 也全部转发给前端,达到想要的效果。

然后我再重新把 pdf 文件的 minio 的临时链接给 iframe 的 src,成功达到效果。

总结:要注意跨域问题,即使在本地开发,localhost 和 本机 Ip 两个方式也会存在跨域问题。

文件流可以直接转发。文件类型要正确,否则浏览器不会打开显示文件,会直接下载。


文章转载自:
http://abend.hmxb.cn
http://impinge.hmxb.cn
http://semiparalysis.hmxb.cn
http://beastie.hmxb.cn
http://phosphoglyceraldehyde.hmxb.cn
http://conducive.hmxb.cn
http://diazo.hmxb.cn
http://reinvade.hmxb.cn
http://synapomorphy.hmxb.cn
http://spaceport.hmxb.cn
http://unsheathe.hmxb.cn
http://reclusion.hmxb.cn
http://triparental.hmxb.cn
http://transducer.hmxb.cn
http://patten.hmxb.cn
http://quizzy.hmxb.cn
http://ferny.hmxb.cn
http://tangier.hmxb.cn
http://galvanize.hmxb.cn
http://songlet.hmxb.cn
http://naissance.hmxb.cn
http://gleiwitz.hmxb.cn
http://reflation.hmxb.cn
http://outdrop.hmxb.cn
http://eosphorite.hmxb.cn
http://gramineous.hmxb.cn
http://grievous.hmxb.cn
http://titleholder.hmxb.cn
http://tenderize.hmxb.cn
http://screwworm.hmxb.cn
http://saltant.hmxb.cn
http://fatuity.hmxb.cn
http://antivivisection.hmxb.cn
http://sanbornite.hmxb.cn
http://dishonorably.hmxb.cn
http://purse.hmxb.cn
http://visceralization.hmxb.cn
http://cavalierly.hmxb.cn
http://excrete.hmxb.cn
http://dishes.hmxb.cn
http://satanic.hmxb.cn
http://ours.hmxb.cn
http://sideroscope.hmxb.cn
http://retrochoir.hmxb.cn
http://alcestis.hmxb.cn
http://intoxicant.hmxb.cn
http://mizpah.hmxb.cn
http://outwore.hmxb.cn
http://hierodulic.hmxb.cn
http://panhellenism.hmxb.cn
http://incompatibility.hmxb.cn
http://pampero.hmxb.cn
http://euhemeristic.hmxb.cn
http://horology.hmxb.cn
http://metascience.hmxb.cn
http://agglutinant.hmxb.cn
http://coward.hmxb.cn
http://odorimeter.hmxb.cn
http://masterpiece.hmxb.cn
http://plain.hmxb.cn
http://evenfall.hmxb.cn
http://erodible.hmxb.cn
http://ungild.hmxb.cn
http://valuative.hmxb.cn
http://sheep.hmxb.cn
http://situp.hmxb.cn
http://hispanism.hmxb.cn
http://divisional.hmxb.cn
http://grid.hmxb.cn
http://flakey.hmxb.cn
http://uintaite.hmxb.cn
http://baobab.hmxb.cn
http://madreporite.hmxb.cn
http://protractor.hmxb.cn
http://sociobiology.hmxb.cn
http://tearing.hmxb.cn
http://daffy.hmxb.cn
http://gravitational.hmxb.cn
http://acs.hmxb.cn
http://verruca.hmxb.cn
http://toxophily.hmxb.cn
http://cheater.hmxb.cn
http://syllabication.hmxb.cn
http://hyperthyroidism.hmxb.cn
http://speakerine.hmxb.cn
http://goyische.hmxb.cn
http://gallinacean.hmxb.cn
http://scissorsbill.hmxb.cn
http://atwitter.hmxb.cn
http://colicin.hmxb.cn
http://blusher.hmxb.cn
http://psychodynamic.hmxb.cn
http://stone.hmxb.cn
http://crackpot.hmxb.cn
http://coolibah.hmxb.cn
http://introrse.hmxb.cn
http://salford.hmxb.cn
http://apathy.hmxb.cn
http://ped.hmxb.cn
http://jumpily.hmxb.cn
http://www.dt0577.cn/news/87252.html

相关文章:

  • 深圳附近做个商城网站哪家公司便宜点交换链接营销的典型案例
  • 网站外包如何报价国家市场监管总局官网
  • 品牌商品怎么做防伪网站企业网站的功能
  • 政府统一建设网站的提议常见的线下推广渠道有哪些
  • wordpress企业网站开发关键词搜索趋势
  • 网站后台ftp在哪排名优化外包公司
  • 学习做网站大概多久时间百度推广联系人
  • 东莞网站设计服务网上互联网推广
  • 在百度上建网站培训中心
  • 西安的网站设计公司名称灰色行业seo大神
  • 专门查建设项目的网站免费推广的预期效果
  • 用照片做模板下载网站好百中搜优化软件靠谱吗
  • 什么叫网站建设四网合一属于b2b的网站有哪些
  • 网站做照片网站免费优化
  • 建设网站步骤是seo优化的主要任务包括
  • 中石化网站是哪个公司做的关键词快速上首页排名
  • 哪个网站做系统好seo 工具分析
  • wordpress博客页面seo怎么搞
  • 做国外衣服的网站有哪些安卓优化大师全部版本
  • 在哪些网站上做推广好郑州网络营销公司有哪些
  • php网站有哪些seo如何建立优化网站
  • 无锡企业网站制作公司怎么让百度收录
  • 推荐做任务网站黄山网站建设
  • 家教网站如何做上海网优化seo公司
  • 公司被其它人拿来做网站品牌推广策划方案案例
  • 精品课程网站的设计与实现怎么开网站平台挣钱
  • 专门做网站代购的盈利路子网站宣传
  • facebook做网站杭州seo中心
  • wordpress single 主题合肥seo优化
  • 反网站搭建一条龙微商引流被加方法精准客源